def show(): 'Show your channel\'s description' service = youtube.service() res = service.channels().list(part='snippet,contentDetails,statistics', mine=True).execute()['items'][0]['snippet'] print(res['description']) return res
def show(video_id): service = youtube.service() res = service.videos().list( part='snippet,statistics', id=video_id ).execute()['items'][0]['snippet']['title'] print(res)
def update(video_id, updated_description): service = youtube.service() res = service.videos().list(part='snippet,statistics', id=video_id).execute()['items'][0]['snippet'] res['description'] = updated_description service.videos().update(part='snippet', body={ 'id': video_id, 'snippet': res }).execute()
def stats(video_id): service = youtube.service() res = service.videos().list( part='snippet,statistics', id=video_id ).execute()['items'][0] print() print('Views: ' + youtube.colors.green + youtube.commify(res['statistics']['viewCount']) + youtube.colors.end) print('Likes: ' + youtube.colors.green + youtube.commify(res['statistics']['likeCount']) + youtube.colors.end) print('Dislikes: ' + youtube.colors.green + youtube.commify(res['statistics']['dislikeCount']) + youtube.colors.end) print('Favorites: ' + youtube.colors.green + youtube.commify(res['statistics']['favoriteCount']) + youtube.colors.end) print()
def update(updated_description): 'Update your channel\'s description' service = youtube.service() my_id = service.channels().list(part='snippet,contentDetails,statistics', mine=True).execute()['items'][0]['id'] service.channels().update(part='brandingSettings', body={ 'id': my_id, 'brandingSettings': { 'channel': { 'description': updated_description } } }).execute()
def update(video_id, updated_description): service = youtube.service() snippet = service.videos().list( part='snippet,statistics', id=video_id ).execute()['items'][0]['snippet'] snippet['title'] = updated_description res = service.videos().update( part='snippet', body={ 'id': video_id, 'snippet': snippet } ).execute() print(res)
def upload(filename, title, description, tags, category, visibility): if visibility not in ['public', 'private', 'unlisted']: print('Invalid visibility. Must be "public" (default), "private", or "unlisted".') body = { 'snippet': { 'title': title, 'description': description, }, 'status': { 'privacyStatus': visibility } } if tags: body['snippet']['tags'] = tags.split(', ') if category: body['snippet']['categoryId'] = str(category) service = youtube.service(version='v3') service.videos().insert( part=','.join(body.keys()), body=body, media_body=MediaFileUpload(filename) ).execute()
def delete(video_id, remove): service = youtube.service() try: vid_name = service.videos().list( part='snippet,statistics', id=video_id ).execute()['items'][0]['snippet']['title'] except: print('{}Video doesn\'t exist.{}'.format(youtube.colors.red, youtube.colors.end)) exit() if not remove: if input('Are your sure you would like to delete "{}{}{}"? Y/N: '.format(youtube.colors.yellow, vid_name, youtube.colors.end)).lower() == 'y': remove = True if remove: try: service.videos().delete( id=video_id ).execute() except HttpError: print('{}You are trying to delete a video you don\'t own.{}'.format(youtube.colors.red, youtube.colors.end)) else: print('Aborted!')