Archived
popglobass
This commit is contained in:
+54
-15
@@ -59,7 +59,46 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
res.set({
|
res.set({
|
||||||
'Access-Control-Allow-Origin': '*'
|
'Access-Control-Allow-Origin': '*'
|
||||||
});
|
});
|
||||||
req.query.id ? res.send(req.query.id) : res.status(400).send('Bad Request');
|
const videos1 = db.get('videos');
|
||||||
|
let videos = JSON.parse(JSON.stringify(videos1.values()));
|
||||||
|
if (req.query.id) {
|
||||||
|
let tmpRes;
|
||||||
|
let row = videos1.getById(req.query.id);
|
||||||
|
if (row.value()) {
|
||||||
|
let tmpA = videos.filter(x => x.id !== req.query.id).map(x => {
|
||||||
|
return {
|
||||||
|
"videoId": x.id,
|
||||||
|
"timesWatched": x.timesWatched,
|
||||||
|
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
||||||
|
"lastSelected": x.lastWatched
|
||||||
|
}
|
||||||
|
})
|
||||||
|
tmpRes = {
|
||||||
|
"site": "site1854.tw.cs.unibo.it",
|
||||||
|
"recommender": req.query.id.toString(),
|
||||||
|
"lastWatched": row.value().lastWatched,
|
||||||
|
"recomended": tmpA
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let tmpA = videos.map(x => {
|
||||||
|
return {
|
||||||
|
"videoId": x.id,
|
||||||
|
"timesWatched": x.timesWatched,
|
||||||
|
"prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason,
|
||||||
|
"lastSelected": x.lastWatched
|
||||||
|
}
|
||||||
|
})
|
||||||
|
tmpRes = {
|
||||||
|
"site": "site1854.tw.cs.unibo.it",
|
||||||
|
"recommender": req.query.id.toString(),
|
||||||
|
"lastWatched": "Never Watched",
|
||||||
|
"recomended": tmpA
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.send(tmpRes)
|
||||||
|
} else
|
||||||
|
res.status(400).send('Bad Request');
|
||||||
});
|
});
|
||||||
|
|
||||||
// OPTIONS /videotrack
|
// OPTIONS /videotrack
|
||||||
@@ -89,9 +128,9 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
for (let j = 0; j < videos[i].reason.length; j++) {
|
for (let j = 0; j < videos[i].reason.length; j++) {
|
||||||
console.log(videos[i].reason[j])
|
console.log(videos[i].reason[j])
|
||||||
if (videos[i].reason[j].prevId === req.query.prevId) {
|
if (videos[i].reason[j].prevId === req.query.prevId) {
|
||||||
let tmp2 = {
|
let tmp2 = {
|
||||||
...videos[i].reason[j],
|
...videos[i].reason[j],
|
||||||
'id': videos[i].id
|
'id': videos[i].id
|
||||||
}
|
}
|
||||||
tmp.push(tmp2);
|
tmp.push(tmp2);
|
||||||
}
|
}
|
||||||
@@ -108,23 +147,23 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
res.set({
|
res.set({
|
||||||
'Access-Control-Allow-Origin': '*'
|
'Access-Control-Allow-Origin': '*'
|
||||||
});
|
});
|
||||||
let setReason = function (reason='Starter', oldArr = [], prevId) {
|
let setReason = function (reason = 'Starter', oldArr = [], prevId) {
|
||||||
let j=oldArr.findIndex(el=>el.prevId===prevId && el.reason===reason)
|
let j = oldArr.findIndex(el => el.prevId === prevId && el.reason === reason)
|
||||||
if (j>=0) {
|
if (j >= 0) {
|
||||||
++oldArr[j].timesWatched;
|
++oldArr[j].timesWatched;
|
||||||
return oldArr
|
return oldArr
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let tmp={
|
let tmp = {
|
||||||
prevId,
|
prevId,
|
||||||
reason,
|
reason,
|
||||||
timesWatched:1
|
timesWatched: 1
|
||||||
}
|
}
|
||||||
oldArr.push(tmp)
|
oldArr.push(tmp)
|
||||||
return oldArr
|
return oldArr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const videos = db.get('videos');
|
const videos = db.get('videos');
|
||||||
const row = videos.getById(req.body.id);
|
const row = videos.getById(req.body.id);
|
||||||
if (row.value()) {
|
if (row.value()) {
|
||||||
@@ -139,7 +178,7 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
"id": req.body.id.toString(),
|
"id": req.body.id.toString(),
|
||||||
"timesWatched": 1,
|
"timesWatched": 1,
|
||||||
"lastWatched": new Date().toISOString(),
|
"lastWatched": new Date().toISOString(),
|
||||||
"reason": setReason(req.body.reason,[],req.body.prevId)
|
"reason": setReason(req.body.reason, [], req.body.prevId)
|
||||||
}
|
}
|
||||||
videos.push(newRow).last().write().then(output => res.send(200, output))
|
videos.push(newRow).last().write().then(output => res.send(200, output))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ class Wikipedia extends Component {
|
|||||||
const musicbrainzBaseUrl = "https://musicbrainz.org/ws/2"; // more readable
|
const musicbrainzBaseUrl = "https://musicbrainz.org/ws/2"; // more readable
|
||||||
let artist = this.props.artist || this.props.artist2;
|
let artist = this.props.artist || this.props.artist2;
|
||||||
let title = this.props.title || this.props.title2;
|
let title = this.props.title || this.props.title2;
|
||||||
console.log('porcodio', P175.toLowerCase(), artist.trim().toLowerCase(), P175.toLowerCase() === artist.trim().toLowerCase())
|
console.log('accipicchia', P175.toLowerCase(), artist.trim().toLowerCase(), P175.toLowerCase() === artist.trim().toLowerCase())
|
||||||
if (P175.toLowerCase() === artist.trim().toLowerCase()) {
|
if (P175.toLowerCase() === artist.trim().toLowerCase()) {
|
||||||
axios
|
axios
|
||||||
.get(`https://musicbrainz.org/ws/2/recording`, {
|
.get(`https://musicbrainz.org/ws/2/recording`, {
|
||||||
|
|||||||
@@ -24,7 +24,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', '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 listSiti = ['1828', '1838', '1839', '1846', '1831', '1827', '1849', '1823', '1863', '1834', '1901', '1859'];
|
||||||
let axiosReq = [];
|
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`)
|
console.log(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`)
|
||||||
|
|||||||
Reference in New Issue
Block a user