def main(): parser = argparse.ArgumentParser( description='Passing parameter for rabbit youtube....') parser.add_argument('--youtube_user_id', '-u', help='youtube user id') parser.add_argument('--playlist_id', '-p', help='youtube playlist id') parser.add_argument('download_to', help='video files download to...') args = parser.parse_args() user_id = args.youtube_user_id play_list_id = args.playlist_id download_to = args.download_to if user_id: print 'going to download all videos uploaded by user_id: %s to: %s' % ( user_id, download_to) youtube_utils.download_all_videos_by_user_id(user_id, download_to) elif play_list_id: print 'going to download all videos from playlist_id:%s to :%s' % ( play_list_id, download_to) youtube_utils.download_all_videos_in_playlist(play_list_id, download_to) else: print 'Please specify youtube_user_id or playlist_id'
def test_download_all_videos_in_playlist_typical(self): playlist_id = "PLyPg0ySdyY2b4EbCZFdGUScU1xC3RjkXo" total_files_downloaded = youtube_utils.download_all_videos_in_playlist(playlist_id, self.destination_folder) downloaded_file_path = os.path.join( self.destination_folder, playlist_id, "cr04UelmPqg_Strava 2014 - cycling_360p.mp4" ) self.assertTrue(os.path.isfile(downloaded_file_path)) self.assertEqual(1336405, os.path.getsize(downloaded_file_path)) self.assertEqual(1, total_files_downloaded)
def test_download_all_videos_in_playlist_typical(self): playlist_id = 'PLyPg0ySdyY2b4EbCZFdGUScU1xC3RjkXo' total_files_downloaded = youtube_utils.download_all_videos_in_playlist( playlist_id, self.destination_folder) downloaded_file_path = os.path.join( self.destination_folder, playlist_id, 'cr04UelmPqg_Strava 2014 - cycling_360p.mp4') self.assertTrue(os.path.isfile(downloaded_file_path)) self.assertEqual(1336405, os.path.getsize(downloaded_file_path)) self.assertEqual(1, total_files_downloaded)
def test_download_all_videos_in_playlist_video_file_existing(self): playlist_id = "PLyPg0ySdyY2b4EbCZFdGUScU1xC3RjkXo" destination_folder = os.path.join(self.destination_folder, playlist_id) youtube_utils.ensure_folder(destination_folder) downloaded_file_path = os.path.join(destination_folder, "cr04UelmPqg_Strava 2014 - cycling_360p.mp4") open(downloaded_file_path, "w+") self.assertEqual(0, os.path.getsize(downloaded_file_path)) total_files_downloaded = youtube_utils.download_all_videos_in_playlist(playlist_id, self.destination_folder) self.assertEqual(0, total_files_downloaded)
def main(): parser = argparse.ArgumentParser(description='Passing parameter for rabbit youtube....') parser.add_argument('--youtube_user_id', '-u', help='youtube user id') parser.add_argument('--playlist_id', '-p', help='youtube playlist id') parser.add_argument('download_to', help='video files download to...') args = parser.parse_args() user_id = args.youtube_user_id play_list_id = args.playlist_id download_to = args.download_to if user_id: print 'going to download all videos uploaded by user_id: %s to: %s' % (user_id, download_to) youtube_utils.download_all_videos_by_user_id(user_id, download_to) elif play_list_id: print 'going to download all videos from playlist_id:%s to :%s' % (play_list_id, download_to) youtube_utils.download_all_videos_in_playlist(play_list_id, download_to) else: print 'Please specify youtube_user_id or playlist_id'
def test_download_all_videos_in_playlist_video_file_existing(self): playlist_id = 'PLyPg0ySdyY2b4EbCZFdGUScU1xC3RjkXo' destination_folder = os.path.join(self.destination_folder, playlist_id) youtube_utils.ensure_folder(destination_folder) downloaded_file_path = os.path.join( destination_folder, 'cr04UelmPqg_Strava 2014 - cycling_360p.mp4') open(downloaded_file_path, 'w+') self.assertEqual(0, os.path.getsize(downloaded_file_path)) total_files_downloaded = youtube_utils.download_all_videos_in_playlist( playlist_id, self.destination_folder) self.assertEqual(0, total_files_downloaded)