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

How can I see my private videos list youtube data api

$
0
0

Hello I am trying retrive number of unlisted videos on my yt channel, which I have 2 right now but still I am gettting output 0 without any error

import osimport google.authfrom google.oauth2.credentials import Credentialsfrom googleapiclient.discovery import buildfrom google.auth.transport.requests import Requestfrom google_auth_oauthlib.flow import InstalledAppFlowchannelid = '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)# Retrieve all unlisted videos on the channelvideos_response = youtube.search().list(    part='id,snippet',    type='video',    channelId=channelid,    maxResults=50).execute()videos = videos_response['items']next_page_token = videos_response.get('nextPageToken')while next_page_token:    videos_response = youtube.search().list(        part='id,snippet',        type='video',        channelId='YOUR_CHANNEL_ID',        maxResults=50,        pageToken=next_page_token    ).execute()    videos += videos_response['items']    next_page_token = videos_response.get('nextPageToken')unlisted_videos_count = sum([1 for item in videos if 'snippet' in item and 'status' in item and 'privacyStatus' in item['status'] and item['status']['privacyStatus'] == 'unlisted'])print('You have', unlisted_videos_count, 'unlisted videos in your channel.')

This is my code I would appreciate your help so much i dont know what i did wrong but i hope i will get help


Viewing all articles
Browse latest Browse all 3831

Trending Articles



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