def videos_related(self): details = self.video_details() if not details.has_key('tags'): dlg = xbmcgui.Dialog() dlg.ok('YouTube', 'Could not find any tags.') else: dlg = xbmcgui.DialogProgress() dlg.create('YouTube', 'Getting related videos') self.yt.set_report_hook(self.progress_handler, dlg) list = None try: tags = details['tags'] list = self.yt.get_videos_by_related(tags, per_page=40) except DownloadError, e: # No data gathered, no need to update list. dlg.close() err_dlg = xbmcgui.Dialog() err_dlg.ok('YouTube', 'There was an error.', e.value) return except DownloadAbort, e: # No data gathered, no need to update list. dlg.close() return
def videos_by_user(self): details = self.video_details() if details is not None and not details.has_key('author'): dlg = xbmcgui.Dialog() dlg.ok('YouTube', 'Could not find author.') elif details is not None: user = details['author'] dlg = xbmcgui.DialogProgress() dlg.create('YouTube', 'Getting videos by %s' % user) self.yt.set_report_hook(self.progress_handler, dlg) try: list = self.yt.get_videos_by_user(user, per_page=40) except DownloadAbort, e: # No data gathered, no need to update list. dlg.close() return except DownloadError, e: # No data gathered, no need to update list. dlg.close() err_dlg = xbmcgui.Dialog() err_dlg.ok('YouTube', 'There was an error.', e.value) return
def show_video_details(self): """Get the details, and show the details window.""" details = self.video_details() dlg = xbmcgui.DialogProgress() dlg.create('YouTube', 'Downloading thumbnail.') self.yt.set_report_hook(self.progress_handler, dlg) if details is not None and details.has_key('thumbnail_url'): try: thumb = self.yt.retrieve(details['thumbnail_url']) except DownloadAbort, e: # Just fall through as a thumbnail is not required. pass except DownloadError, e: err_dlg = xbmcgui.Dialog() err_dlg.ok('YouTube', 'There was an error.', e.value)
list = self.yt.get_videos_by_related(tags, per_page=40) except DownloadError, e: # No data gathered, no need to update list. dlg.close() err_dlg = xbmcgui.Dialog() err_dlg.ok('YouTube', 'There was an error.', e.value) return except DownloadAbort, e: # No data gathered, no need to update list. dlg.close() return dlg.close() if self.update_list(list): if details.has_key('title'): lbl = 'Videos related to \'%s\'' % details['title'] else: lbl = 'Related videos' self.get_control('Feed Label').setLabel(lbl) self.list_state = YouTubeGUI.CONTENT_STATE_VIDEO else: dlg = xbmcgui.Dialog() dlg.ok('YouTube', 'No related videos found.') def play_clip(self, id): """Get the url for the id and start playback.""" try: file = self.download_data(id, self.yt.get_video_url) self.player.play(str(file))