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

How can I scrape private videos of my youtube channel youtube data api

$
0
0

How can I scrape my private or draft video wih youtube data api python.The code I have written only allows me to get my public videos video id.I want it to give me video id of every private video or draft video i have

Here's my code

import osimport google.authfrom google.oauth2.credentials import Credentialsfrom googleapiclient.discovery import buildfrom google.auth.transport.requests import Requestfrom google_auth_oauthlib.flow import InstalledAppFlowfrom googleapiclient.errors import HttpErrorchannelid = 'CHANNEL_ID_HERE'# Set up OAuth2 credentialscreds = Noneif os.path.exists('token.json'):    creds = Credentials.from_authorized_user_file('token.json')if not creds or not creds.valid:    if creds and creds.expired and creds.refresh_token:        creds.refresh(Request())    else:        flow = InstalledAppFlow.from_client_secrets_file('youtube.json', scopes=['https://www.googleapis.com/auth/youtube.force-ssl'])        creds = flow.run_local_server(port=0)    # Save the credentials for the next run    with open('token.json', 'w') as token_file:        token_file.write(creds.to_json())    with open('token.json', 'w') as token_file:        token_file.write(creds.to_json())# Set up YouTube API clientyoutube = build('youtube', 'v3', credentials=creds)try:    # make a request to the API to retrieve a list of videos uploaded by the authenticated user    response = youtube.videos().list(        part='id',        myRating='like',        maxResults=50  # increase or decrease as needed    ).execute()    # extract the video IDs from the response    video_ids = [item['id'] for item in response['items']]    print('Video IDs:', video_ids)except HttpError as error:    print('An error occurred:', error)

How can I modify it to give me private or draft video id's ( Btw I have 1 private and 1 draft video on my channel whose video id I am trying to get)


Viewing all articles
Browse latest Browse all 3831

Trending Articles



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