Archived
cambiata api key
This commit is contained in:
@@ -1 +1 @@
|
||||
AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig
|
||||
'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg'
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
process.env['NODE_ENV'] = 'production';
|
||||
process.env.APIKEY = 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig';
|
||||
'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' = 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg';
|
||||
const express = require('express');
|
||||
const compression = require('compression')
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
+10
-10
@@ -8,8 +8,6 @@ import Card from "react-bootstrap/lib/Card";
|
||||
import moment from 'moment';
|
||||
import momentDurationFormat from 'moment-duration-format'; //eslint-disable-line no-unused-vars
|
||||
import './css/VideoInfo.scss';
|
||||
|
||||
|
||||
const ytclear = require('@c0b41/ytclear');
|
||||
|
||||
class VideoInfo extends React.Component {
|
||||
@@ -79,39 +77,35 @@ class VideoInfo extends React.Component {
|
||||
}),
|
||||
]).then(axios.spread((responseA1,responseA2)=>{
|
||||
console.log(responseA1.data, responseA2.data);
|
||||
|
||||
}))
|
||||
}),
|
||||
error => { }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
getInfoComments() {
|
||||
return axios.all([
|
||||
axios.get('https://www.googleapis.com/youtube/v3/videos', { //Richiesta per tutte le info sul video
|
||||
params: {
|
||||
'part': 'snippet,contentDetails,statistics,topicDetails',
|
||||
'id': this.state.videoId,
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig' // process.env.APIKEY in production
|
||||
'key': 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' // 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' in production
|
||||
}
|
||||
}), axios.get('https://www.googleapis.com/youtube/v3/commentThreads', { //Richiesta per ottenere i commenti del video
|
||||
params: {
|
||||
'part': 'snippet',
|
||||
'videoId': this.state.videoId,
|
||||
'order': 'relevance',
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig' // process.env.APIKEY in production
|
||||
'key': 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' // 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' in production
|
||||
}
|
||||
})])
|
||||
.then(axios.spread((videosResponse, commentThreadResponse) => {
|
||||
this.isArtistOrTitle(ytclear(videosResponse.data.items[0].snippet.title).split('-'));
|
||||
// this.isArtistOrTitle(ytclear(videosResponse.data.items[0].snippet.title).split('-'));
|
||||
this.setState({
|
||||
VideoDetails: videosResponse.data.items[0],
|
||||
comments: commentThreadResponse.data.items,
|
||||
others: {
|
||||
artist: null,
|
||||
title: videosResponse.data.items[0].snippet.title
|
||||
title2: ytclear(videosResponse.data.items[0].snippet.title).split('-')[1]
|
||||
},
|
||||
isLoaded: true
|
||||
});
|
||||
@@ -127,6 +121,11 @@ class VideoInfo extends React.Component {
|
||||
static getDerivedStateFromProps(nextProps, prevState) {
|
||||
if(nextProps.videoId !== prevState.videoId)
|
||||
return { videoId: nextProps.videoId };
|
||||
else if(nextProps.location.state)
|
||||
return { others: {
|
||||
artist: nextProps.location.state.artist,
|
||||
title: nextProps.location.state.title
|
||||
}}
|
||||
return null;
|
||||
}
|
||||
componentDidMount() {
|
||||
@@ -208,6 +207,7 @@ class VideoInfo extends React.Component {
|
||||
<Tab className="text-white" eventKey="wikipedia" title="Wikipedia">
|
||||
<Wikipedia
|
||||
title={this.state.others.title}
|
||||
title2={this.state.others.title2}
|
||||
artist={this.state.others.artist}
|
||||
videoId={this.state.videoId}
|
||||
/>
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ class VideoList extends React.Component {
|
||||
params: {
|
||||
part: 'snippet',
|
||||
id: idToLookFor.slice(0, 50).toString(),
|
||||
key: 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig', // process.env.APIKEY in production
|
||||
key: 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg', // 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' in production
|
||||
fields: 'items(id,snippet/thumbnails/medium)'
|
||||
}
|
||||
}),
|
||||
@@ -56,7 +56,7 @@ class VideoList extends React.Component {
|
||||
params: {
|
||||
part: 'snippet',
|
||||
id: idToLookFor.slice(50, 100).toString(),
|
||||
key: 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig', // process.env.APIKEY in production
|
||||
key: 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg', // 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' in production
|
||||
fields: 'items(id,snippet/thumbnails/medium)'
|
||||
}
|
||||
}),
|
||||
@@ -65,7 +65,7 @@ class VideoList extends React.Component {
|
||||
params: {
|
||||
part: 'snippet',
|
||||
id: idToLookFor.slice(100, finalChunk).toString(),
|
||||
key: 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig', // process.env.APIKEY in production
|
||||
key: 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg', // 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg' in production
|
||||
fields: 'items(id,snippet/thumbnails/medium)'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,7 +17,9 @@ class Wikipedia extends Component {
|
||||
isWikiLoaded: false,
|
||||
isWDataLoaded: false,
|
||||
isMBLoaded: false,
|
||||
isLoaded: false
|
||||
isLoaded: false,
|
||||
wikidatakeys: null,
|
||||
wikipediakeys: null
|
||||
};
|
||||
|
||||
ISO_8601toYYYY(a) {
|
||||
@@ -64,7 +66,7 @@ class Wikipedia extends Component {
|
||||
if (wikidataP1651Res.data.results.bindings.length) { // got a match
|
||||
this.getWikidataPage(wdk.simplify.sparqlResults(wikidataP1651Res.data))// set in state wikidata
|
||||
.then(() => {
|
||||
if (this.state.wikidata.claims.P435) {
|
||||
if (this.state.wikidata.claims.P435) { // p435 == musicbrainzWorkId
|
||||
axios.get(`${musicbrainzBaseUrl}/work/${this.state.wikidata.claims.P435[0].mainsnak.datavalue.value}`, { // get musicbrainz info
|
||||
params: {
|
||||
'inc': 'artist-rels url-rels',
|
||||
@@ -105,7 +107,7 @@ class Wikipedia extends Component {
|
||||
else { //oof
|
||||
axios.get(`${musicbrainzBaseUrl}/work`, {
|
||||
params: {
|
||||
'query': this.state.props.title.trim(),
|
||||
'query': 'undefined' === typeof this.state.props.title ? this.state.props.title2 : this.state.props.title,
|
||||
'limit': 1,
|
||||
'offset': 0,
|
||||
'fmt': 'json'
|
||||
@@ -131,7 +133,7 @@ class Wikipedia extends Component {
|
||||
this.getWikidataPage(wikidataEntityRegEx.exec(a.url.resource)) //.then(() => this.setState({ isWikiLoaded: true }));
|
||||
}
|
||||
else { // oof
|
||||
wikijs().find(this.state.props.title).then(data => console.log('asd', data)) // find by props.title
|
||||
wikijs().find('undefined' === typeof this.state.props.title? this.state.props.title2.trim(): this.state.props.title.trim()).then(data => console.log('asd', data)) // find by props.title
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -145,13 +147,13 @@ class Wikipedia extends Component {
|
||||
return {
|
||||
props: {
|
||||
videoId: nextProps.videoId,
|
||||
artist: nextProps.artist,
|
||||
title: nextProps.title
|
||||
},
|
||||
isWikiLoaded: false,
|
||||
isWDataLoaded: false,
|
||||
isMBLoaded: false,
|
||||
isLoaded: false
|
||||
isLoaded: false,
|
||||
wikidatakeys: null,
|
||||
wikipediakeys: null
|
||||
};
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class RecommenderRandom extends Component{
|
||||
'type' : 'video', //che contiene tutti i generi di musica
|
||||
'maxResults': '21',
|
||||
'pageToken' : pageToken,
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig' // process.env.APIKEY in production
|
||||
'key': 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg'
|
||||
}
|
||||
}).then(
|
||||
response => {
|
||||
|
||||
@@ -33,7 +33,7 @@ class Related extends Component {
|
||||
'relatedToVideoId' : this.state.videoId,
|
||||
'type' : 'video',
|
||||
'maxResults' : '21',
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig' // process.env.APIKEY in production
|
||||
'key': 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg'
|
||||
}
|
||||
}).then(
|
||||
response => {
|
||||
|
||||
+53
-17
@@ -1,10 +1,13 @@
|
||||
import React from 'react';
|
||||
import axios from 'axios';
|
||||
import { Card, Col } from 'react-bootstrap';
|
||||
|
||||
class Search extends React.Component {
|
||||
|
||||
state = {
|
||||
query: '',
|
||||
isLoaded: false,
|
||||
error: null,
|
||||
res: null
|
||||
}
|
||||
|
||||
@@ -16,20 +19,12 @@ class Search extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
console.log('called didmo');
|
||||
}
|
||||
|
||||
// shouldComponentUpdate(nextProps, nextState) {
|
||||
|
||||
// }
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
console.log('called didup');
|
||||
if(new RegExp("[0-9A-Za-z_-]{10}[048AEIMQUYcgkosw]").test(this.state.query.toString()))
|
||||
axios.get('https://www.googleapis.com/youtube/v3/videos',{
|
||||
if (new RegExp("[0-9A-Za-z_-]{10}[048AEIMQUYcgkosw]").test(this.state.query.toString()))
|
||||
axios.get('https://www.googleapis.com/youtube/v3/videos', {
|
||||
params: {
|
||||
'part':'id',
|
||||
'part': 'id',
|
||||
'id': this.state.query,
|
||||
'key': process.env.APIKEY ? process.env.APIKEY : 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig',
|
||||
'key': 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg',
|
||||
'field': 'pageInfo/resultsPerPage'
|
||||
}
|
||||
}).then(
|
||||
@@ -46,6 +41,38 @@ class Search extends React.Component {
|
||||
this.youtubeSearch();
|
||||
}
|
||||
|
||||
// shouldComponentUpdate(nextProps, nextState) {
|
||||
|
||||
// }
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
console.log('called didup');
|
||||
if (prevState.query !== this.props.match.params.query)
|
||||
if (new RegExp("[0-9A-Za-z_-]{10}[048AEIMQUYcgkosw]").test(this.state.query.toString()))
|
||||
axios.get('https://www.googleapis.com/youtube/v3/videos', {
|
||||
params: {
|
||||
'part': 'id',
|
||||
'id': this.state.query,
|
||||
'key': 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg',
|
||||
'field': 'pageInfo/resultsPerPage'
|
||||
}
|
||||
}).then(
|
||||
res => {
|
||||
res.data.pageInfo.resultsPerPage ?
|
||||
this.props.history.push('/video/' + this.state.query) :
|
||||
this.youtubeSearch()
|
||||
},
|
||||
error => {
|
||||
console.error(error)
|
||||
this.setState({
|
||||
error
|
||||
})
|
||||
}
|
||||
)
|
||||
else
|
||||
this.youtubeSearch();
|
||||
}
|
||||
|
||||
// componentWillUnmount() {
|
||||
|
||||
// }
|
||||
@@ -59,13 +86,14 @@ class Search extends React.Component {
|
||||
'type': 'video',
|
||||
'maxResults': 30,
|
||||
'topicId': '/m/04rlf, /m/02jjt',
|
||||
'key': process.env.APIKEY ? process.env.APIKEY : 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
|
||||
'key': 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg'
|
||||
}
|
||||
}).then(
|
||||
res => {
|
||||
console.log(res.data);
|
||||
this.setState({
|
||||
res: res.data
|
||||
res: res.data,
|
||||
isLoaded: true
|
||||
})
|
||||
},
|
||||
error => { console.error(error) }
|
||||
@@ -73,12 +101,20 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
return <React.Fragment>Error: {this.state.error.message}</React.Fragment>;
|
||||
} else if (!this.state.isLoaded) {
|
||||
return <React.Fragment>Loading...</React.Fragment>;
|
||||
} else {
|
||||
return (
|
||||
<div>
|
||||
<span>{this.state.query} keyword</span>
|
||||
</div>
|
||||
<Col>
|
||||
{this.state.res.data.items.map(item => (<Card></Card>
|
||||
|
||||
))}
|
||||
</Col>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Search;
|
||||
@@ -57,7 +57,7 @@ class fvitali extends React.Component {
|
||||
params: {
|
||||
part: 'snippet',
|
||||
id: idToLookFor.toString(),
|
||||
key: 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig',
|
||||
key: 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg',
|
||||
fields: 'items(id,snippet/thumbnails/medium,snippet/title)'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -48,7 +48,7 @@ class popGlobaleAssoluta extends React.Component {
|
||||
params: {
|
||||
part: 'snippet',
|
||||
id: idToLookFor.toString(),
|
||||
key: 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig',
|
||||
key: 'AIzaSyBYSHhu7AwZqT1JK3x4G8Yzs7iRqoS_QUg',
|
||||
fields: 'items(id,snippet/thumbnails/medium,snippet/title)'
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user