def runOnce(self): """ Create pafy objects for tests. """ if hasattr(Test, "hasrun"): return Test.quick = os.environ.get("quick") Test.videos = VIDEOS if not Test.quick else [] Test.playlists = PLAYLISTS if not Test.quick else [] for video in Test.videos: time.sleep(0 if Test.quick else self.delay) video['pafy'] = pafy.new(video['identifier']) video['streams'] = video['pafy'].streams video['best'] = video['pafy'].getbest() video['bestaudio'] = video['pafy'].getbestaudio() video['bestvideo'] = video['pafy'].getbestvideo() # get urls for age restricted vids if video['pafy'].videoid == "07FYdnEawAQ": _ = video['pafy'].streams[0].url _ = video['pafy'].streams[1].url_https del _ for playlist in Test.playlists: playlist['fetched'] = pafy.get_playlist(playlist['identifier']) Test.hasrun = True
def runOnce(self): """ Create pafy objects for tests. """ if hasattr(Test, "hasrun"): return Test.quick = os.environ.get("quick") Test.videos = VIDEOS if not Test.quick else [] Test.playlists = PLAYLISTS if not Test.quick else [] for video in Test.videos: time.sleep(0 if Test.quick else self.delay) video['pafy'] = pafy.new(video['identifier']) video['streams'] = video['pafy'].streams video['best'] = video['pafy'].getbest() video['bestaudio'] = video['pafy'].getbestaudio() # get urls for age restricted vids if video['pafy'].videoid == "07FYdnEawAQ": _ = video['pafy'].streams[0].url _ = video['pafy'].streams[1].url_https del _ for playlist in Test.playlists: playlist['fetched'] = pafy.get_playlist(playlist['identifier']) Test.hasrun = True
def resolveYoutubePlaylist(data): with infoLock: if data['type'] == "youtube": print 'Loading playlist data for ' + data['id'] try: playlist = pafy.get_playlist(data['id']) for item in playlist['items']: data = dict(id=item['pafy'].playlist_meta['encrypted_id'], type='youtube', format='high') data.update(item['pafy'].playlist_meta) print "Found video in playlist: ", data['id'] yield data except Exception as e: print "Error fetching youtube playlist ", e
def runOnce(self): if hasattr(Test, "hasrun"): return Test.quick = os.environ.get("quick") Test.videos = VIDEOS if not Test.quick else [] Test.playlists = PLAYLISTS if not Test.quick else [] for video in Test.videos: time.sleep(0 if Test.quick else self.delay) video['pafy'] = pafy.new(video['identifier']) video['streams'] = video['pafy'].streams video['best'] = video['pafy'].getbest() video['bestaudio'] = video['pafy'].getbestaudio() for playlist in Test.playlists: playlist['fetched'] = pafy.get_playlist(playlist['identifier']) Test.hasrun = True