Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'isomorphic-fetch'
- var array = [
- {
- "id": "natusvinceretv",
- "name": "Na'Vi Dota2",
- "title": "Natus Vincere dota team channel"
- },
- {
- "id": "Dendiboss",
- "name": "Dendi",
- "title": "Na'Vi.Dendi channel"
- },
- {
- "id": "VirtusproDOTA",
- "name": "Virtuspro",
- "title": "Virtus.pro dota team channel"
- },
- {
- "id": "Teamicecret",
- "name": "Secret Team",
- "title": "Secret Team dota channel"
- },
- {
- "id": "hrdota2",
- "name": "HellRaisers",
- "title": "HellRaisers dota team channel"
- },
- {
- "id": "noobfromua",
- "name": "NoobFromUA",
- "title": "Dota 2 Channel NoobFromUA"
- },
- {
- "name": "Dota2RuHub",
- "youtubeId": "UCA6WssVVOv_xSB-PdQ7vYYA",
- "title": "Канал посвященный игре Dota2 и международным турнирам по этой игре.Официальный YouTube канал русскоязычных экспертов и журналистов игры Dota2."
- },
- {
- "name": "Storm Studio",
- "youtubeId": "UCpPpXo2ATn0BQsMpCTTI0yg",
- "title": "Storm Studio"
- },
- {
- "id": "DarduinMyMenlon",
- "name": "Dota Watafak",
- "title": "Suscribe or Feed!!!"
- }
- ]
- let all = []
- getAllVideos(array)
- function getAllVideos (array) {
- array.map((item) => {
- const name = item.id
- const url = 'https://www.googleapis.com/youtube/v3/channels?' +
- 'part=contentDetails&' +
- 'forUsername=' + name + '&' +
- 'key=AIzaSyB857qDfoTXwdCBaIFDqxEUD3j2W_hCMVg'
- makeFetch(url)
- })
- }
- function makeFetch (url) {
- fetch(url).then((response) => {
- return response.json()
- }).then((json) => {
- const pid = json.items[0].id
- // let arr = []
- // arr.push(pid)
- // makeXuyetch(pid)
- makeXuyetch(pid)
- }).catch(function (ex) {
- console.log('parsing failed', ex)
- })
- }
- function makeXuyetch (pid) {
- const vidResults = 8
- const url = 'https://www.googleapis.com/youtube/v3/search?' +
- 'maxResults=' + vidResults + '&' +
- 'part=snippet&' +
- 'channelId=' + pid + '&' +
- 'order=date&' +
- 'key=AIzaSyB857qDfoTXwdCBaIFDqxEUD3j2W_hCMVg'
- fetch(url).then((response) => {
- return response.json()
- }).then((json) => {
- const gg = json.items
- gg.map((item) => {
- all.push(item)
- })
- }).catch(function (ex) {
- console.log('parsing failed', ex)
- })
- }
- console.log(all)
- // const reduced = all.reduce((acc, x) => { return acc.concat(x) }, []);
- //
- // console.log(reduced)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement