Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3638

populating dataframe with youtube api

$
0
0
list2=['PewDiePie', 'jacksepticeye', 'iDubbbzTV', 'Markiplier','MarkiplierGAME',  'EminemMusic','EdSheeran', 'TaylorSwift', 'CNN', 'FoxNews', 'CBCNews', 'ABCNews', 'NBCNews', 'SkyNews', 'ESPN', 'UFC', 'BellatorMMA', 'NBA', 'KhanAcademy', 'Sentdex', 'CrashCourse', 'BigThink', 'DoctorMike']from googleapiclient.discovery import buildimport pandas as pddf=pd.DataFrame()for i in range(len(list2)):   request= youtube.channels().list(part='snippet',forUsername=list2[i])   response= request.execute()   print(response['items'][0]['snippet']['description'])#channel description   channel_description= response['items'][0]['snippet']['description']   request= youtube.channels().list(part='contentDetails',forUsername=list2[i])   response= request.execute()   print(response['items'][0]['contentDetails']['relatedPlaylists']['uploads'])#upload_code   upload_code = response['items'][0]['contentDetails']['relatedPlaylists']['uploads']   request= youtube.playlistItems().list(part ='snippet',playlistId=upload_code ,maxResults=5) #retrieving videos   response= request.execute()   print(response['items'][0]['snippet']['description'])   print(response['items'][0]['snippet']['title'])   dfdict={"channel_title": list2[i],"channel_description": channel_description,"vid1_title":response['items'][0]['snippet']['title'],"vid1_description":response['items'][0]['snippet']['description'],}   df = df.assign(**dfdict)print('/////////////////////////////////////')df

I am trying to populate the dataframe "df" with the channel name, channel description, title and description of the first video pulled. so far with this method i have had no luck as it simply returns an empty dataframe. in the code i store the data in the dictionary "dfdict" then attempt to use the assign command to store it in the df.


Viewing all articles
Browse latest Browse all 3638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>