def _sync_positions_yt(self): for index, item in enumerate(self.items): if item.position != index: item.position = index resource = get_api_request_dict(item.to_metadata()) response = self.api_service.playlistItems().insert( body=resource, part='snippet').execute() logging.info(response)
def set_youtube_privacy(self): """Update YouTube privacy setting for this video.""" properties = { 'id': self.id, 'status.privacyStatus': self.privacy, } resource = get_api_request_dict(properties) response = self.api_service.videos().update(body=resource, part='status').execute() logging.info(response)
def sync_metadata_to_youtube(self): """Set metadata info in YouTube.""" properties = { 'id': self.id, 'snippet.title': self.title, 'snippet.description': self.description, 'snippet.tags[]': self.tags } resource = get_api_request_dict(properties) response = self.api_service.playlists().update( body=resource, part='snippet').execute() logging.info(response)
def sync_metadata_to_youtube(self): """Set title etc in YouTube. :return: """ properties = { 'id': self.id, 'snippet.title': self.title, 'snippet.description': self.description, 'snippet.tags[]': self.tags, 'snippet.categoryId': self.category_id } resource = get_api_request_dict(properties) response = self.api_service.videos().update(body=resource, part='snippet').execute() logging.info(response)
def add_video_yt(self, video_id, position=0): """Insert a video into this playlist. Update YouTube as well.""" properties = { 'snippet.playlistId': self.id, 'snippet.resourceId.kind': 'youtube#video', 'snippet.resourceId.videoId': video_id, 'snippet.position': position } resource = get_api_request_dict(properties) response = self.api_service.playlistItems().insert( body=resource, part='snippet').execute() logging.info(response) response['snippet']['position'] = position item = PlaylistItem.from_metadata(response, api_service=self.api_service) self.items.insert(position, item) return item