Archived
Yojimbo
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 74 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 66 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 88 KiB |
+14
-6
@@ -8,19 +8,27 @@ export default class AboutUs extends Component {
|
||||
<Container>
|
||||
<Row className="show-Container text-center">
|
||||
<Col xs={12} sm={4} className="person-wrapper">
|
||||
<Image src="assets/person-1.jpg" roundedCircle className="profile-pic"/>
|
||||
<Image src="assets/person-1.jpg" roundedCircle className="profile-pic" />
|
||||
<h3>Matteo Scorzafava</h3>
|
||||
<p>That's a crooked tree. We'll send him to Washington. These little son of a guns hide in your brush and you just have to push them out.</p>
|
||||
<p></p>
|
||||
</Col>
|
||||
<Col xs={12} sm={4} className="person-wrapper">
|
||||
<Image src="assets/person-2.jpg" roundedCircle className="profile-pic"/>
|
||||
<Image src="assets/person-2.jpg" roundedCircle className="profile-pic" />
|
||||
<h3>Simone Ferrari</h3>
|
||||
<p>That's a crooked tree. We'll send him to Washington. These little son of a guns hide in your brush and you just have to push them out.</p>
|
||||
<p>Recommender Random<br/>
|
||||
Recommender Related<br/>
|
||||
Recommender Similarity Genere<br/>
|
||||
Box delle informazioni relative al video
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={12} sm={4} className="person-wrapper">
|
||||
<Image src="assets/person-3.jpg" roundedCircle className="profile-pic"/>
|
||||
<Image src="assets/person-3.jpg" roundedCircle className="profile-pic" />
|
||||
<h3>Gregorio Giacchetti</h3>
|
||||
<p>That's a crooked tree. We'll send him to Washington. These little son of a guns hide in your brush and you just have to push them out.</p>
|
||||
<p>Recommender Recent<br/>
|
||||
Recommender fvitali<br/>
|
||||
Gestione della barra dei recommender<br/>
|
||||
AboutUs
|
||||
</p>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
|
||||
+7
-5
@@ -34,19 +34,21 @@ class App extends React.Component {
|
||||
exact: true,
|
||||
strict: false
|
||||
});
|
||||
if (prevState.videoId !== null){
|
||||
if (prevState.videoId !== null) {
|
||||
if (idMatch && idMatch.params.id !== prevState.videoId) {
|
||||
localStorage.setItem('prevId', prevState.videoId)
|
||||
localStorage.setItem('lastId', idMatch.params.id)
|
||||
return { videoId: idMatch.params.id };
|
||||
}
|
||||
else{
|
||||
else {
|
||||
if (idMatch && idMatch.params.id !== prevState.videoId) {
|
||||
localStorage.setItem('lastId', idMatch.params.id)
|
||||
return { videoId: idMatch.params.id };
|
||||
}
|
||||
return null;
|
||||
}}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +63,7 @@ class App extends React.Component {
|
||||
xs="12"
|
||||
lg={this.state.isInfoToggled ? { span: 8, offset: 0, order: 2 } : { span: 9, offset: 0, order: 2 }}
|
||||
className="blackBg align-content-center">
|
||||
<Col xs="12" lg={this.state.isInfoToggled ? { span: 10, offset: 1} : { span: 10, offset: 1 }}>
|
||||
<Col xs="12" lg={this.state.isInfoToggled ? { span: 10, offset: 1 } : { span: 10, offset: 1 }}>
|
||||
<ReactHeight onHeightReady={height => { this.setState({ playerHeight: height }) }}>
|
||||
<VideoPlayer videoId={this.state.videoId} />
|
||||
</ReactHeight>
|
||||
@@ -70,7 +72,7 @@ class App extends React.Component {
|
||||
<Col
|
||||
xs="12"
|
||||
lg={this.state.isInfoToggled ? { span: 4, order: 1 } : { span: 3, order: 1 }}
|
||||
className={this.state.isInfoToggled ? "": "blackBg"}
|
||||
className={this.state.isInfoToggled ? "" : "blackBg"}
|
||||
style={window.innerWidth < 992 ?
|
||||
{ 'overflow': "auto", 'display': 'fixed', 'maxHeight': this.state.playerHeight * 1.4 + 'px' } :
|
||||
{ 'overflow': "auto", 'maxHeight': `${this.state.playerHeight}px` }}>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Row, Col } from 'react-bootstrap';
|
||||
import { Switch, Route } from 'react-router';
|
||||
import Random from './reccomenders/Random';
|
||||
import Related from './reccomenders/Related';
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ class VideoInfo extends React.Component {
|
||||
});
|
||||
let index = videosResponse.data.items[0].topicDetails.relevantTopicIds.indexOf('/m/04rlf');
|
||||
videosResponse.data.items[0].topicDetails.relevantTopicIds.splice(index, 1);
|
||||
localStorage.setItem('lastTopic',videosResponse.data.items[0].topicDetails.relevantTopicIds);
|
||||
localStorage.setItem('lastTopic', videosResponse.data.items[0].topicDetails.relevantTopicIds);
|
||||
}), error => {
|
||||
console.error(error);
|
||||
this.setState({
|
||||
@@ -71,7 +71,7 @@ class VideoInfo extends React.Component {
|
||||
return (
|
||||
<span className="text-white">
|
||||
<span>{}</span>
|
||||
Error: {error.message} -- {error.response.data && error.response.data.error.message.replace(htmlRegEx,'')}
|
||||
Error: {error.message} -- {error.response.data && error.response.data.error.message.replace(htmlRegEx, '')}
|
||||
</span>
|
||||
);
|
||||
} else if (!isLoaded) {
|
||||
|
||||
+6
-4
@@ -23,7 +23,7 @@ class VideoList extends React.Component {
|
||||
response => {
|
||||
this.shuffleArray(response.data);
|
||||
this.getThumbnails(response.data)
|
||||
.then(videoList => localStorage.setItem('fixedVideoList',JSON.stringify(videoList)));
|
||||
.then(videoList => localStorage.setItem('fixedVideoList', JSON.stringify(videoList)));
|
||||
},
|
||||
// Note: it's important to handle errors here
|
||||
// instead of a catch() block so that we don't swallow
|
||||
@@ -74,15 +74,17 @@ class VideoList extends React.Component {
|
||||
])
|
||||
.then(
|
||||
axios.spread((res1, res2, res3) => {
|
||||
[...res1.data.items,...res2.data.items,...res3.data.items]
|
||||
[...res1.data.items, ...res2.data.items, ...res3.data.items]
|
||||
.map(resCurrentValue =>
|
||||
Object.defineProperty(
|
||||
videoItems.find(videoItem => {
|
||||
return videoItem.videoID === resCurrentValue.id;
|
||||
}),
|
||||
'thumbnail',
|
||||
{ value: resCurrentValue.snippet.thumbnails.medium.url,
|
||||
enumerable: true }
|
||||
{
|
||||
value: resCurrentValue.snippet.thumbnails.medium.url,
|
||||
enumerable: true
|
||||
}
|
||||
)
|
||||
);
|
||||
this.setState({
|
||||
|
||||
+19
-19
@@ -14,12 +14,12 @@ class VideoPlayer extends React.Component {
|
||||
autoplay: 0,
|
||||
modestbranding: 1,
|
||||
fs: 0,
|
||||
iv_load_policy:3,
|
||||
iv_load_policy: 3,
|
||||
rel: 0,
|
||||
origin//: 'http://site1854.tw.cs.unibo.it'
|
||||
}
|
||||
},
|
||||
promise1: Promise,
|
||||
promise1: null,
|
||||
promise2: Promise,
|
||||
outsideReject1: null,
|
||||
outsideReject2: null
|
||||
@@ -45,9 +45,9 @@ class VideoPlayer extends React.Component {
|
||||
console.error('Player error: ', event);
|
||||
}
|
||||
|
||||
_onPlay(event) {}
|
||||
_onPlay(event) { }
|
||||
|
||||
_onReady(event) {}
|
||||
_onReady(event) { }
|
||||
|
||||
_onStateChange(event) {
|
||||
let timerId1, timerId2;
|
||||
@@ -94,20 +94,19 @@ class VideoPlayer extends React.Component {
|
||||
})
|
||||
.then(
|
||||
response => console.info(response.data),
|
||||
error => this.setState({error})//console.error(error, videoIdWatched.toString())
|
||||
error => this.setState({ error })//console.error(error, videoIdWatched.toString())
|
||||
);
|
||||
// local storage logic for recent reccomender
|
||||
let tmp = JSON.parse(localStorage.getItem('lastWatched'))
|
||||
let j=tmp.findIndex(el=>el.id.toString()===videoIdWatched.toString())
|
||||
if (j<0) {
|
||||
let j = tmp.findIndex(el => el.id.toString() === videoIdWatched.toString())
|
||||
if (j < 0) {
|
||||
|
||||
if (localStorage['prevId']==='1')
|
||||
{
|
||||
if (localStorage['prevId'] === '1') {
|
||||
//per primo video
|
||||
tmp.push({
|
||||
'id': videoIdWatched.toString(),
|
||||
'lastWatched' : new Date(),
|
||||
'timesWatched' : 1,
|
||||
'lastWatched': new Date(),
|
||||
'timesWatched': 1,
|
||||
'prevVideos': []
|
||||
})
|
||||
}
|
||||
@@ -115,21 +114,22 @@ class VideoPlayer extends React.Component {
|
||||
//Prima volta video generico
|
||||
tmp.push({
|
||||
'id': videoIdWatched.toString(),
|
||||
'lastWatched' : new Date(),
|
||||
'timesWatched' : 1,
|
||||
'prevVideos' : [{id:[localStorage["prevId"]].toString()}]
|
||||
'lastWatched': new Date(),
|
||||
'timesWatched': 1,
|
||||
'prevVideos': [{ id: [localStorage["prevId"]].toString() }]
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
//altre volte
|
||||
tmp[j].timesWatched++;
|
||||
tmp[j].lastWatched= new Date();
|
||||
let z=tmp[j].prevVideos.findIndex(el=>el.id === localStorage["prevId"].toString())
|
||||
if (z<0){
|
||||
tmp[j].lastWatched = new Date();
|
||||
let z = tmp[j].prevVideos.findIndex(el => el.id === localStorage["prevId"].toString())
|
||||
if (z < 0) {
|
||||
tmp[j].prevVideos.push({
|
||||
'id': localStorage["prevId"].toString()
|
||||
})}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ class VideoPlayer extends React.Component {
|
||||
break;
|
||||
}
|
||||
})
|
||||
.finally(()=>{this.setState({promise2: null, outsideReject2: null})});
|
||||
.finally(() => { this.setState({ promise2: null, outsideReject2: null }) });
|
||||
}
|
||||
}
|
||||
_onStateChange = this._onStateChange.bind(this);
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class Wikipedia extends Component {
|
||||
})
|
||||
.then(resRecordingQuery => {
|
||||
let x = resRecordingQuery.data.relations.map(x => x['target-type'] === 'work' ? x.work.id : "").toString();
|
||||
console.log(x,'resRecordingQuery.data true', resRecordingQuery.data)
|
||||
console.log(x, 'resRecordingQuery.data true', resRecordingQuery.data)
|
||||
}, err => { console.error(err) })
|
||||
}
|
||||
, err => console.error(err))
|
||||
|
||||
+9
-9
@@ -9,16 +9,16 @@ import App from './App';
|
||||
import registerServiceWorker from './registerServiceWorker';
|
||||
import { HashRouter, BrowserRouter } from 'react-router-dom'; // eslint-disable-line
|
||||
|
||||
localStorage['lastWatched'] ? function (){}() : localStorage.setItem('lastWatched', JSON.stringify([]))
|
||||
localStorage['first'] ? function (){}() : localStorage.setItem('first', JSON.stringify([]))
|
||||
localStorage['prevId'] ? function (){}() : localStorage.setItem('prevId','1')
|
||||
localStorage['lastId'] ? function (){}() : localStorage.setItem('lastId','0J2QdDbelmY')
|
||||
localStorage['currentVideoInfo']? function(){}() : localStorage.setItem('currentVideoInfo', JSON.stringify({
|
||||
'id':'0J2QdDbelmY',
|
||||
'artist':'Seven Nation Army',
|
||||
'genre':'Rock'
|
||||
localStorage['lastWatched'] ? function () { }() : localStorage.setItem('lastWatched', JSON.stringify([]))
|
||||
localStorage['first'] ? function () { }() : localStorage.setItem('first', JSON.stringify([]))
|
||||
localStorage['prevId'] ? function () { }() : localStorage.setItem('prevId', '1')
|
||||
localStorage['lastId'] ? function () { }() : localStorage.setItem('lastId', '0J2QdDbelmY')
|
||||
localStorage['currentVideoInfo'] ? function () { }() : localStorage.setItem('currentVideoInfo', JSON.stringify({
|
||||
'id': '0J2QdDbelmY',
|
||||
'artist': 'Seven Nation Army',
|
||||
'genre': 'Rock'
|
||||
}));
|
||||
localStorage['lastTopic']? function(){}() : localStorage.setItem('lastTopic','/m/04rlf');
|
||||
localStorage['lastTopic'] ? function () { }() : localStorage.setItem('lastTopic', '/m/04rlf');
|
||||
|
||||
ReactDOM.render(<BrowserRouter><App /></BrowserRouter>, document.getElementById('root'));
|
||||
registerServiceWorker();
|
||||
|
||||
+16
-15
@@ -1,20 +1,20 @@
|
||||
import React, { Component } from 'react';
|
||||
import axios from "axios";
|
||||
import createpageToken from 'youtube-page-token';
|
||||
import {Card,Col} from "react-bootstrap";
|
||||
import {Link} from "react-router-dom";
|
||||
import { Card, Col } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import moment from "moment";
|
||||
|
||||
class RecommenderRandom extends Component{
|
||||
state={
|
||||
items : [],
|
||||
class RecommenderRandom extends Component {
|
||||
state = {
|
||||
items: [],
|
||||
}
|
||||
|
||||
ISO_8601parse(a) {
|
||||
return moment(a, moment.ISO_8601).format('ddd, DD/MM/YYYY hh:mm:ss');
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
componentDidMount() {
|
||||
let pos = Math.floor(Math.random() * 500);
|
||||
let pageToken = createpageToken(pos); /* createPageToken(pos) restituisce il pageToken relativo al numero
|
||||
di pagina che gli viene passato(in questo caso pos) che verrai poi usato
|
||||
@@ -23,16 +23,16 @@ class RecommenderRandom extends Component{
|
||||
axios.get("https://www.googleapis.com/youtube/v3/search", {
|
||||
params: {
|
||||
'part': 'snippet',
|
||||
'topicId' : '/m/04rlf', //Filtro per la musica.In questo caso il valore è quello della parent directory
|
||||
'type' : 'video', //che contiene tutti i generi di musica
|
||||
'topicId': '/m/04rlf', //Filtro per la musica.In questo caso il valore è quello della parent directory
|
||||
'type': 'video', //che contiene tutti i generi di musica
|
||||
'maxResults': '21',
|
||||
'pageToken' : pageToken,
|
||||
'pageToken': pageToken,
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
|
||||
}
|
||||
}).then(
|
||||
response => {
|
||||
this.setState({
|
||||
items : response.data.items,
|
||||
items: response.data.items,
|
||||
})
|
||||
},
|
||||
error => {
|
||||
@@ -41,16 +41,17 @@ class RecommenderRandom extends Component{
|
||||
)
|
||||
}
|
||||
|
||||
render(){
|
||||
render() {
|
||||
const ISO_8601parse = this.ISO_8601parse;
|
||||
return (<React.Fragment>
|
||||
{this.state.items.map(function (item,index) {
|
||||
return(
|
||||
{this.state.items.map(function (item, index) {
|
||||
return (
|
||||
<Col key={index} md='4'>
|
||||
<Card>
|
||||
<Link
|
||||
to={{
|
||||
pathname: '/video/' + item.id.videoId,
|
||||
search: "?ref=Random"
|
||||
}}
|
||||
>
|
||||
<Card.Img
|
||||
@@ -59,7 +60,7 @@ class RecommenderRandom extends Component{
|
||||
/>
|
||||
<Card.ImgOverlay>
|
||||
<Card.Title className="bg-dark d-inline text-white">
|
||||
{item.snippet.title}<br/>
|
||||
{item.snippet.title}<br />
|
||||
{item.snippet.channelTitle} - {ISO_8601parse(item.snippet.publishedAt)}
|
||||
</Card.Title>
|
||||
</Card.ImgOverlay>
|
||||
@@ -68,7 +69,7 @@ class RecommenderRandom extends Component{
|
||||
</Col>
|
||||
)
|
||||
})}
|
||||
</React.Fragment> );
|
||||
</React.Fragment>);
|
||||
}
|
||||
}
|
||||
export default RecommenderRandom;
|
||||
@@ -56,7 +56,6 @@ class Recent extends React.Component {
|
||||
|
||||
|
||||
render() {
|
||||
const recentVideoList = JSON.parse(localStorage.getItem('lastWatched'))
|
||||
const { error, isLoaded, items } = this.state;
|
||||
if (error) {
|
||||
return (
|
||||
@@ -77,6 +76,7 @@ class Recent extends React.Component {
|
||||
<Link
|
||||
to={{
|
||||
pathname: '/video/' + item.id,
|
||||
search: "?ref=Recent"
|
||||
}}
|
||||
>
|
||||
<Card.Img
|
||||
|
||||
+21
-20
@@ -1,14 +1,14 @@
|
||||
import React, { Component } from 'react';
|
||||
import axios from 'axios';
|
||||
import {Link} from "react-router-dom";
|
||||
import {Card,Col} from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Card, Col } from "react-bootstrap";
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
class Related extends Component {
|
||||
state={
|
||||
videoId : localStorage['lastId'],
|
||||
items : []
|
||||
state = {
|
||||
videoId: localStorage['lastId'],
|
||||
items: []
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ class Related extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
axios.get("https://www.googleapis.com/youtube/v3/search",{
|
||||
params:{
|
||||
axios.get("https://www.googleapis.com/youtube/v3/search", {
|
||||
params: {
|
||||
'part': 'snippet',
|
||||
'relatedToVideoId' : this.props.match.params.id,
|
||||
'type' : 'video',
|
||||
'maxResults' : '22',
|
||||
'relatedToVideoId': this.props.match.params.id,
|
||||
'type': 'video',
|
||||
'maxResults': '22',
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
|
||||
}
|
||||
}).then(
|
||||
@@ -37,14 +37,14 @@ class Related extends Component {
|
||||
)
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps,prevState){
|
||||
if (prevProps.match.params.id !== this.props.match.params.id){
|
||||
axios.get("https://www.googleapis.com/youtube/v3/search",{
|
||||
params:{
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevProps.match.params.id !== this.props.match.params.id) {
|
||||
axios.get("https://www.googleapis.com/youtube/v3/search", {
|
||||
params: {
|
||||
'part': 'snippet',
|
||||
'relatedToVideoId' : this.props.match.params.id,
|
||||
'type' : 'video',
|
||||
'maxResults' : '22',
|
||||
'relatedToVideoId': this.props.match.params.id,
|
||||
'type': 'video',
|
||||
'maxResults': '22',
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
|
||||
}
|
||||
}).then(
|
||||
@@ -64,13 +64,14 @@ class Related extends Component {
|
||||
const ISO_8601parse = this.ISO_8601parse;
|
||||
return (
|
||||
<React.Fragment>
|
||||
{this.state.items.map(function (item,index) {
|
||||
return(
|
||||
{this.state.items.map(function (item, index) {
|
||||
return (
|
||||
<Col key={index} md="4">
|
||||
<Card>
|
||||
<Link
|
||||
to={{
|
||||
pathname: '/video/' + item.id.videoId,
|
||||
search: "?ref=Related"
|
||||
}}
|
||||
>
|
||||
<Card.Img
|
||||
@@ -79,7 +80,7 @@ class Related extends Component {
|
||||
/>
|
||||
<Card.ImgOverlay>
|
||||
<Card.Title className="bg-dark d-inline text-white">
|
||||
{item.snippet.title}<br/>
|
||||
{item.snippet.title}<br />
|
||||
{item.snippet.channelTitle} - {ISO_8601parse(item.snippet.publishedAt)}
|
||||
</Card.Title>
|
||||
</Card.ImgOverlay>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import axios from 'axios';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Card, Col, Media } from 'react-bootstrap';
|
||||
import { Col, Media } from 'react-bootstrap';
|
||||
|
||||
class Search extends React.Component {
|
||||
|
||||
@@ -117,6 +117,7 @@ class Search extends React.Component {
|
||||
as="li" className="media mx-5 my-1 suggItem"
|
||||
to={{
|
||||
pathname: '/video/' + item.id.videoId,
|
||||
search: "?ref=Search"
|
||||
}}>
|
||||
<img
|
||||
width={240}
|
||||
|
||||
+13
-11
@@ -14,8 +14,8 @@ class fvitali extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
axios.get('http://site1825.tw.cs.unibo.it/TW/globpop', {
|
||||
'params':{
|
||||
'id':this.props.match.params.id //se 'id'=>'Id', allora tutti video random, sennò anche per genere simile
|
||||
'params': {
|
||||
'id': this.props.match.params.id //se 'id'=>'Id', allora tutti video random, sennò anche per genere simile
|
||||
}
|
||||
}).then(
|
||||
response => {
|
||||
@@ -56,7 +56,7 @@ class fvitali extends React.Component {
|
||||
'thumbnail':
|
||||
{ value: resCurrentValue.snippet.thumbnails.medium.url },
|
||||
'name':
|
||||
{value: resCurrentValue.snippet.title}
|
||||
{ value: resCurrentValue.snippet.title }
|
||||
})
|
||||
);
|
||||
this.setState({
|
||||
@@ -78,19 +78,20 @@ class fvitali extends React.Component {
|
||||
);
|
||||
} else if (!isLoaded) {
|
||||
return (
|
||||
<Col className="text-center">
|
||||
<Col className="text-center">
|
||||
<div className="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
|
||||
</Col>
|
||||
);
|
||||
} else {
|
||||
if(window.innerWidth < 992){
|
||||
return(
|
||||
if (window.innerWidth < 992) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
{items.map(item=>( <Col md="4">
|
||||
{items.map(item => (<Col md="4">
|
||||
<Card key={item.videoID}>
|
||||
<Link
|
||||
to={{
|
||||
pathname: '/video/' + item.videoID,
|
||||
search: "?ref=fvitali"
|
||||
}}
|
||||
>
|
||||
<Card.Img
|
||||
@@ -109,8 +110,8 @@ class fvitali extends React.Component {
|
||||
</Col>))}
|
||||
</React.Fragment>
|
||||
);
|
||||
}else{
|
||||
return(
|
||||
} else {
|
||||
return (
|
||||
<ul className="list-unstyled">{
|
||||
items.map(item => (
|
||||
<Link
|
||||
@@ -118,7 +119,7 @@ class fvitali extends React.Component {
|
||||
as="li" className="media mx-5 my-1 suggItem"
|
||||
to={{
|
||||
pathname: `/video/${item.videoID}`,
|
||||
search: '?ref=fvitali587'
|
||||
search: '?ref=fvitali'
|
||||
}}>
|
||||
<img
|
||||
width={240}
|
||||
@@ -135,7 +136,8 @@ class fvitali extends React.Component {
|
||||
</Link>
|
||||
))
|
||||
}</ul>
|
||||
);}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React, { Component } from 'react';
|
||||
import axios from 'axios';
|
||||
import {Card, Col, Tab, Tabs} from "react-bootstrap";
|
||||
import { Card, Col } from "react-bootstrap";
|
||||
import createpageToken from 'youtube-page-token';
|
||||
import {Link} from "react-router-dom";
|
||||
import { Link } from "react-router-dom";
|
||||
import moment from "moment";
|
||||
|
||||
class genreSimilarity extends Component {
|
||||
state={
|
||||
items : []
|
||||
state = {
|
||||
items: []
|
||||
};
|
||||
|
||||
ISO_8601parse(a) {
|
||||
@@ -24,8 +24,8 @@ class genreSimilarity extends Component {
|
||||
'topicId': localStorage['lastTopic'],
|
||||
'type': 'video',
|
||||
'maxResults': '21',
|
||||
'order' : 'viewCount',
|
||||
'pageToken' : pageToken,
|
||||
'order': 'viewCount',
|
||||
'pageToken': pageToken,
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
|
||||
}
|
||||
}).then(
|
||||
@@ -40,16 +40,17 @@ class genreSimilarity extends Component {
|
||||
)
|
||||
}
|
||||
|
||||
render(){
|
||||
render() {
|
||||
const ISO_8601parse = this.ISO_8601parse;
|
||||
return (<React.Fragment>
|
||||
{this.state.items.map(function (item,index) {
|
||||
return(
|
||||
{this.state.items.map(function (item, index) {
|
||||
return (
|
||||
<Col key={index} md='4'>
|
||||
<Card>
|
||||
<Link
|
||||
to={{
|
||||
pathname: '/video/' + item.id.videoId,
|
||||
search: "?ref=genreSimilarity"
|
||||
}}
|
||||
>
|
||||
<Card.Img
|
||||
@@ -58,7 +59,7 @@ class genreSimilarity extends Component {
|
||||
/>
|
||||
<Card.ImgOverlay>
|
||||
<Card.Title className="bg-dark d-inline text-white">
|
||||
{item.snippet.title}<br/>
|
||||
{item.snippet.title}<br />
|
||||
{item.snippet.channelTitle} - {ISO_8601parse(item.snippet.publishedAt)}
|
||||
</Card.Title>
|
||||
</Card.ImgOverlay>
|
||||
@@ -67,7 +68,7 @@ class genreSimilarity extends Component {
|
||||
</Col>
|
||||
)
|
||||
})}
|
||||
</React.Fragment> );
|
||||
</React.Fragment>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class popGlobaleAssoluta extends React.Component {
|
||||
// let listSiti = ['1828', '1829', '1838', '1839', '1846', '1822', '1847', '1831', '1827', '1848', '1824', '1830', '1836', '1850', '1849', '1851', '1861', '1823', '1863', '1834', '1904', '1906', '1901', '1862', '1859'];
|
||||
let listSiti = ['1828', '1838', '1839', '1846', '1847', '1831', '1827', '1849', '1823', '1863', '1834', '1901', '1859'];
|
||||
let axiosReq = [];
|
||||
for(let i=0; i<listSiti.length; i++){
|
||||
for (let i = 0; i < listSiti.length; i++) {
|
||||
console.log(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`)
|
||||
axiosReq.push(axios.get(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`, {
|
||||
'params': {
|
||||
@@ -36,7 +36,7 @@ class popGlobaleAssoluta extends React.Component {
|
||||
}
|
||||
Promise.all(axiosReq)
|
||||
.then(axios.spread((...res) => {
|
||||
console.log(res.map(x=>x.data))
|
||||
console.log(res.map(x => x.data))
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class popGlobaleAssoluta extends React.Component {
|
||||
|
||||
|
||||
render() {
|
||||
const { error, isLoaded, items, headers } = this.state;
|
||||
const { error, isLoaded, items } = this.state;
|
||||
if (error) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
@@ -99,6 +99,7 @@ class popGlobaleAssoluta extends React.Component {
|
||||
<Link
|
||||
to={{
|
||||
pathname: '/video/' + item.videoID,
|
||||
search: "?ref=popGlobaleAssoluta"
|
||||
}}
|
||||
>
|
||||
<Card.Img
|
||||
|
||||
@@ -18,10 +18,10 @@ class popLocaleAss extends React.Component {
|
||||
componentDidMount() {
|
||||
axios
|
||||
.get('http://site1854.tw.cs.unibo.it/videotrack')
|
||||
.then(res=>{
|
||||
.then(res => {
|
||||
this.getThumbnailsNames(res.data.sort((a, b) => a.timesWatched - b.timesWatched).reverse());
|
||||
}
|
||||
,error=>this.setState({error}))
|
||||
, error => this.setState({ error }))
|
||||
}
|
||||
|
||||
// shouldComponentUpdate(nextProps, nextState) {
|
||||
@@ -60,9 +60,9 @@ class popLocaleAss extends React.Component {
|
||||
'thumbnail':
|
||||
{ value: resCurrentValue.snippet.thumbnails.medium.url },
|
||||
'name':
|
||||
{value: resCurrentValue.snippet.title},
|
||||
{ value: resCurrentValue.snippet.title },
|
||||
'description':
|
||||
{value: resCurrentValue.snippet.description }
|
||||
{ value: resCurrentValue.snippet.description }
|
||||
})
|
||||
);
|
||||
this.setState({
|
||||
@@ -89,6 +89,7 @@ class popLocaleAss extends React.Component {
|
||||
as="li" className="media mx-5 my-1 suggItem"
|
||||
to={{
|
||||
pathname: '/video/' + item.id,
|
||||
search: "?ref=popLocaleAss"
|
||||
}}>
|
||||
<img
|
||||
width={240}
|
||||
@@ -99,7 +100,7 @@ class popLocaleAss extends React.Component {
|
||||
/>
|
||||
<Media.Body>
|
||||
<h5>{item.name}</h5>
|
||||
<p>{item.description.substring(0,200)}</p>
|
||||
<p>{item.description.substring(0, 200)}</p>
|
||||
<p>Visto: {item.timesWatched} volte <br />
|
||||
Reccomender: popLocaleAss</p>
|
||||
</Media.Body>
|
||||
|
||||
@@ -19,12 +19,10 @@ class PopRelLoc extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
let tmp = JSON.parse(localStorage.getItem('lastWatched'));
|
||||
let j=tmp.findIndex(el=>el.id === localStorage["lastId"]);
|
||||
let j = tmp.findIndex(el => el.id === localStorage["lastId"]);
|
||||
//this.getThumbnailsNames(tmp[j].prevVideos);
|
||||
if (tmp.length === 0 || localStorage["prevId"] === '1')
|
||||
{this.getThumbnailsNames(JSON.parse(localStorage.getItem('first')))}
|
||||
else
|
||||
{this.getThumbnailsNames(tmp[j].prevVideos)}
|
||||
if (tmp.length === 0 || localStorage["prevId"] === '1') { this.getThumbnailsNames(JSON.parse(localStorage.getItem('first'))) }
|
||||
else { this.getThumbnailsNames(tmp[j].prevVideos) }
|
||||
|
||||
}
|
||||
|
||||
@@ -88,6 +86,7 @@ class PopRelLoc extends React.Component {
|
||||
<Link
|
||||
to={{
|
||||
pathname: '/video/' + item.id,
|
||||
search: "?ref=popRelLoc"
|
||||
}}
|
||||
>
|
||||
<Card.Img
|
||||
|
||||
@@ -17,15 +17,15 @@ class similarityArtist extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
let timerId1;
|
||||
let promise = new Promise ((resolve,reject) => {
|
||||
timerId1 = window.setInterval(()=>{
|
||||
if(localStorage['lastId'] === JSON.parse(localStorage['currentVideoInfo']).id)
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
timerId1 = window.setInterval(() => {
|
||||
if (localStorage['lastId'] === JSON.parse(localStorage['currentVideoInfo']).id)
|
||||
resolve(true)
|
||||
},1000)
|
||||
}, 1000)
|
||||
})
|
||||
promise.then(()=>{
|
||||
promise.then(() => {
|
||||
window.clearInterval(timerId1);
|
||||
this.setState({artist: JSON.parse(localStorage['currentVideoInfo']).artist})
|
||||
this.setState({ artist: JSON.parse(localStorage['currentVideoInfo']).artist })
|
||||
axios.get('https://www.googleapis.com/youtube/v3/search', {
|
||||
params: {
|
||||
'part': 'snippet',
|
||||
@@ -37,12 +37,19 @@ class similarityArtist extends React.Component {
|
||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
|
||||
}
|
||||
}).then(
|
||||
res =>
|
||||
res => {
|
||||
let j = res.data.items.findIndex(el => el.id.videoId === localStorage['lastId'])
|
||||
if (j >= 0)
|
||||
res.data.items.splice(j, 1);
|
||||
this.setState({
|
||||
res: res.data,
|
||||
isLoaded: true
|
||||
})
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
,
|
||||
|
||||
error => this.setState({
|
||||
error
|
||||
})
|
||||
@@ -85,7 +92,7 @@ class similarityArtist extends React.Component {
|
||||
as="li" className="media mx-5 my-1 suggItem"
|
||||
to={{
|
||||
pathname: '/video/' + item.id.videoId,
|
||||
search:"?ref=similarityArtist"
|
||||
search: "?ref=similarityArtist"
|
||||
}}>
|
||||
<img
|
||||
width={240}
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function register() {
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
const swUrl = `${process.env.PUBLIC_URL?process.env.PUBLIC_URL:'http://localhost:8000'}/service-worker.js`;
|
||||
const swUrl = `${process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'http://localhost:8000'}/service-worker.js`;
|
||||
|
||||
if (isLocalhost) {
|
||||
// This is running on localhost. Lets check if a service worker still exists or not.
|
||||
|
||||
Reference in New Issue
Block a user