Archived
ricerca wikidata con id youtube
This commit is contained in:
+6
-2
@@ -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 */}
|
||||
<Tabs defaultActiveKey="a" id="uncontrolled-tab-example">
|
||||
<Tab eventKey="a" title="A">
|
||||
<Wikipedia query={ this.props.location.state ? this.props.location.state.title : VideoDetails.snippet.title } />
|
||||
<Wikipedia title={ this.props.location.state ? this.props.location.state.title : VideoDetails.snippet.title }
|
||||
artist={ this.props.location.state ? this.props.location.state.artist : '' }
|
||||
videoId={ this.props.match.params.id}
|
||||
/>
|
||||
</Tab>
|
||||
<Tab eventKey="b" title="B">
|
||||
<p>{}</p>
|
||||
<p>{ ytclear(this.state.VideoDetails.snippet.title)}</p>
|
||||
</Tab>
|
||||
<Tab eventKey="c" title="C">
|
||||
<p>C</p>
|
||||
|
||||
+1
-1
@@ -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} */}
|
||||
|
||||
+43
-22
@@ -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 <React.Fragment>Error: {error.message}</React.Fragment>;
|
||||
} else if (!isLoaded) {
|
||||
@@ -86,7 +106,8 @@ class Wikipedia extends Component {
|
||||
} else {
|
||||
return (
|
||||
<div>
|
||||
{/* <p>risultato ricerca wikipedia: { data.results[0] }</p> */}
|
||||
<p>risultato ricerca wikipedia:</p>
|
||||
<pre>{ }</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user