![]() This function is from the YouTube API documentation. Get a list of videos from based Search term: def youtube_keyword(client, **kwargs): kwargs = remove_empty_kwargs(**kwargs) response = arch().list( **kwargs ).execute() return response It seemed pretty straight forward, so I figured I would search by keyword and and label each video with the search term: The goal was to get a list of videos and then label each video by subject. To connect to the API, run this and get an authorization code: client = get_authenticated_service() I have also imported pandas to organize what will be extracted from the response. These functions are copied directly from the YouTube ‘quickstart’ (for python) page. #create an empty list for the text lecture_texts = #iterate over the list of file names for file in filenames: tree = ET.parse('xmls/ if kwargs is not None: for key, value in ems(): if value: good_kwargs = value return good_kwargs # this is the path to the XML files path = 'xmls' # we use the os library to encode the path folder = os.fsencode(path) #here we get a list of XML files in the directory filenames = filenames output:Ĭ. Set the path to your XML files and get a list of the file names (in my case I put the files in a folder in my current working directory). Import libraries import os import as ETī. (For rigor, this part of the example shows the case for multiple XML files.)Ī. You can pip install the library if you don’t already have it. Next, we will see how to clean this file using the XML Etree library. Now you should have an xml file in a directory that contains the text of the subtitles and some extra XML. Note: Be sure to add ‘.xml’ to end, just in case the files are in a directory with multiple file types (Ideally you have a directory dedicated to the subtitles, but that may not be the case.) ![]() Right Click anywhere on the page and select ‘Save Page As’ and save it in your preferred directory.
0 Comments
Leave a Reply. |