def test_get_service(self): credentials = Credentials(invalid=False) self._storage.get = MagicMock(return_value=credentials) run_flow = MagicMock() auth = Authenticator(self._storage, run_flow) assert auth.get_service(credentials).playlists
scope = 'https://www.googleapis.com/auth/youtube' flow = flow_from_clientsecrets(config['secrets_file'], scope, message="Something went wrong!") def partial_run_flow(args): return run_flow(flow, storage, args) auth = Authenticator(storage, partial_run_flow) now = datetime.now() argparser.add_argument('--title', help='playlist title', default='{0}-{1}-{2}'.format(now.year, now.month, now.day)) argparser.add_argument('--workouts', help="Workout video ids", default=[]) args = argparser.parse_args() video_ids = args.workouts if isinstance(video_ids, str): video_ids = video_ids.split(',') print(video_ids) service = auth.get_service(auth.get_credentials(args)) store = PlaylistStore(service) store.insert(args.title, video_ids)