diff --git a/package-lock.json b/package-lock.json index ee5ab49..05c6472 100644 --- a/package-lock.json +++ b/package-lock.json @@ -839,6 +839,21 @@ "to-fast-properties": "^2.0.0" } }, + "@c0b41/ytclear": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@c0b41/ytclear/-/ytclear-1.0.0.tgz", + "integrity": "sha512-XRlrOlcUZhFURt6x1G1q40Oq4SvYr3j0NAcZeahx4N3em8eAY8831jPjeRBT+nQd762yYINanlfUX2uaG3UaaA==", + "requires": { + "minimist": "^1.1.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, "@csstools/convert-colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@csstools/convert-colors/-/convert-colors-1.4.0.tgz", @@ -5488,8 +5503,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -5507,13 +5521,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5526,18 +5538,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -5640,8 +5649,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -5651,7 +5659,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5664,20 +5671,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5694,7 +5698,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -5767,8 +5770,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -5778,7 +5780,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -5854,8 +5855,7 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -5885,7 +5885,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5903,7 +5902,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5942,13 +5940,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.2", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -14968,6 +14964,11 @@ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" }, + "wikidata-sdk": { + "version": "5.15.9", + "resolved": "https://registry.npmjs.org/wikidata-sdk/-/wikidata-sdk-5.15.9.tgz", + "integrity": "sha512-I40/v7vW3gw1aLZ9/Yao4+I5ETPoOgE+3dt4rQxJkS510ow4nPb6DTtvA95zppmtDMDSNCNA1a7HN6FNRtAFQg==" + }, "wikijs": { "version": "4.8.1", "resolved": "https://registry.npmjs.org/wikijs/-/wikijs-4.8.1.tgz", diff --git a/package.json b/package.json index dedacce..6dea5d2 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "@c0b41/ytclear": "^1.0.0", "axios": "^0.18.0", "bootstrap": "^4.1.3", "express": "^4.16.4", @@ -13,6 +14,7 @@ "react-router-dom": "^4.3.1", "react-scripts": "2.1.1", "react-youtube": "^7.8.0", + "wikidata-sdk": "^5.15.9", "wikijs": "^4.8.1" }, "scripts": { diff --git a/src/VideoInfo.js b/src/VideoInfo.js index 1dc6f4a..6829f8b 100644 --- a/src/VideoInfo.js +++ b/src/VideoInfo.js @@ -3,6 +3,7 @@ import Wikipedia from './areainfo/Wikipedia'; import { Col, Tabs, Tab } from 'react-bootstrap'; import axios from 'axios'; + const ytclear = require('@c0b41/ytclear'); class VideoInfo extends Component { constructor(props) { @@ -88,10 +89,13 @@ {/* codice per tabs reccomenders */} - + -

{}

+

{ ytclear(this.state.VideoDetails.snippet.title)}

C

diff --git a/src/VideoList.js b/src/VideoList.js index c098398..3331893 100644 --- a/src/VideoList.js +++ b/src/VideoList.js @@ -129,7 +129,7 @@ class VideoList extends React.Component { pathname: '/video/' + item.videoID, state: { artist: item.artist, - title: item.title +' '+ item.artist + title: item.title } }}> {/* {item.artist} - {item.title} {item.videoID} {item.category} */} diff --git a/src/areainfo/Wikipedia.js b/src/areainfo/Wikipedia.js index 6c11a29..13fecba 100644 --- a/src/areainfo/Wikipedia.js +++ b/src/areainfo/Wikipedia.js @@ -1,13 +1,16 @@ import React, { Component } from 'react'; // import PropTypes from 'prop-types'; import wikijs from 'wikijs'; +import wdk from 'wikidata-sdk'; +import axios from 'axios'; class Wikipedia extends Component { constructor(props) { super(props); this.state = { - data: {}, - infobox: {}, + wikidata: null, + wikipedia: null, + spareobj: {}, error: null, isLoaded: false }; @@ -36,25 +39,42 @@ class Wikipedia extends Component { // } componentWillMount() { - wikijs() - .find(this.props.query, this.raffina) - .then( - data => { - this.setState({ - data, - isLoaded: true - }); - console.log(data.html()); - //this.getWikiBox(data.results[0]); - }, - error => { - console.error(error); - this.setState({ - isLoaded: true, - error - }); + // wikijs() + // .find(this.props.query, this.raffina) + // .then( + // data => { + // this.setState({ + // data, + // isLoaded: true + // }); + // console.log(data.html()); + // //this.getWikiBox(data.results[0]); + // }, + // error => { + // console.error(error); + // this.setState({ + // isLoaded: true, + // error + // }); + // } + // ); + axios + .get(wdk.getReverseClaims('P1651', this.props.videoId)) // P1651 is youtube_video_id property + .then(wikidataSearchRes => { + if (wikidataSearchRes.data.results.bindings.length) { + axios.get(wdk.getEntities(wdk.simplify.sparqlResults(wikidataSearchRes.data), 'en')) + .then(wikidataPage => { + this.setState({ + isLoaded: true, + wikidata: wikidataPage.data.entities[Object.keys(wikidataPage.data.entities)[0]] + }); + console.info('wikidata baby',this.state.wikidata); + }); + } else { + console.log('oof'); } - ); + }); + } // componentWillReceiveProps(nextProps) { @@ -78,7 +98,7 @@ class Wikipedia extends Component { // } render() { - const { data, error, isLoaded } = this.state; + const { wikidata, error, isLoaded } = this.state; if (error) { return Error: {error.message}; } else if (!isLoaded) { @@ -86,7 +106,8 @@ class Wikipedia extends Component { } else { return (
- {/*

risultato ricerca wikipedia: { data.results[0] }

*/} +

risultato ricerca wikipedia:

+
{  }
); }