Skip to content

Instantly share code, notes, and snippets.

@Samiulcse
Last active May 16, 2022 07:00
Show Gist options
  • Save Samiulcse/21f94e05ab0378667564b3295aa3b84d to your computer and use it in GitHub Desktop.
Save Samiulcse/21f94e05ab0378667564b3295aa3b84d to your computer and use it in GitHub Desktop.

Revisions

  1. Md. Samiul Islam revised this gist May 16, 2022. 1 changed file with 0 additions and 17 deletions.
    17 changes: 0 additions & 17 deletions Youtube Video
    Original file line number Diff line number Diff line change
    @@ -40,21 +40,4 @@ loadYoutube(){
    // this.loadYoutubeVideos(playListId, res.data.nextPageToken)
    // }
    });
    },
    loadSections() {
    axios.get(`/api/home-sections?page=${this.current_page}&per_page=${this.per_page}&profile_id=${(this.currentProfile ? this.currentProfile.id : '')}`)
    .then((response) => {
    response.data.data.forEach(val => {
    this.sections.push(val)
    if (val.type == 'ad') {
    this.contentAd = true
    this.adSectionIds.push(val.id)
    setTimeout(() => {
    this.initSmallAdvertiseSlider(`small_advertise_slider${val.id}`)
    }, 200)
    }
    this.loadMore = false
    });
    this.last_page = response.data.meta.last_page
    });
    },
  2. Md. Samiul Islam revised this gist May 16, 2022. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions Youtube Video
    Original file line number Diff line number Diff line change
    @@ -40,4 +40,21 @@ loadYoutube(){
    // this.loadYoutubeVideos(playListId, res.data.nextPageToken)
    // }
    });
    },
    loadSections() {
    axios.get(`/api/home-sections?page=${this.current_page}&per_page=${this.per_page}&profile_id=${(this.currentProfile ? this.currentProfile.id : '')}`)
    .then((response) => {
    response.data.data.forEach(val => {
    this.sections.push(val)
    if (val.type == 'ad') {
    this.contentAd = true
    this.adSectionIds.push(val.id)
    setTimeout(() => {
    this.initSmallAdvertiseSlider(`small_advertise_slider${val.id}`)
    }, 200)
    }
    this.loadMore = false
    });
    this.last_page = response.data.meta.last_page
    });
    },
  3. Md. Samiul Islam created this gist May 16, 2022.
    43 changes: 43 additions & 0 deletions Youtube Video
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    loadYoutube(){
    axios.create().get('https://www.googleapis.com/youtube/v3/channels', {
    params: {
    part: "contentDetails",
    id: process.env.MIX_YOUTUBE_CHANNEL_ID,
    key: process.env.MIX_GOOGLE_API_KEY,
    },
    headers: {
    'Authorization': '',
    }
    }).then((response) => {
    this.loadYoutubeVideos(response.data.items[0].contentDetails.relatedPlaylists.uploads, '')
    });
    },
    loadYoutubeVideos(playListId, pageToken){
    axios.create().get('https://www.googleapis.com/youtube/v3/playlistItems', {
    params: {
    part: "contentDetails,snippet",
    playlistId: playListId,
    key: process.env.MIX_GOOGLE_API_KEY,
    maxResults: this.maxResults,
    pageToken: pageToken
    },
    headers: {
    'Authorization': '',
    }
    }).then((res) => {
    if(pageToken == ''){
    this.ytVideos = res.data.items.map(item => {
    return {
    id: item.contentDetails.videoId,
    type: 'y',
    playlist: playListId,
    preview_image_thumbs: item.snippet.thumbnails.medium.url
    }
    })
    }

    // if(res.data.nextPageToken){
    // this.loadYoutubeVideos(playListId, res.data.nextPageToken)
    // }
    });
    },