def _download_clip(slug, args): print_out("<dim>Looking up clip...</dim>") clip = twitch.get_clip(slug) if not clip: raise ConsoleError("Clip '{}' not found".format(slug)) print_out( "Found: <green>{}</green> by <yellow>{}</yellow>, playing <blue>{}</blue> ({})" .format(clip["title"], clip["broadcaster"]["displayName"], clip["game"]["name"], utils.format_duration(clip["durationSeconds"]))) url = _get_clip_url(clip, args) print_out("<dim>Selected URL: {}</dim>".format(url)) url_path = urlparse(url).path extension = Path(url_path).suffix filename = "{}_{}{}".format(clip["broadcaster"]["login"], utils.slugify(clip["title"]), extension) print_out("Downloading clip...") download_file(url, filename) print_out("Downloaded: {}".format(filename))
def _download_clip(slug, args): print_out("<dim>Looking up clip...</dim>") clip = twitch.get_clip(slug) print_out("Found: <green>{}</green> by <yellow>{}</yellow>, playing <blue>{}</blue> ({})".format( clip["title"], clip["broadcaster"]["displayName"], clip["game"]["name"], utils.format_duration(clip["durationSeconds"]) )) print_out("\nAvailable qualities:") qualities = clip["videoQualities"] for n, q in enumerate(qualities): print_out("{}) {} [{} fps]".format(n + 1, q["quality"], q["frameRate"])) no = utils.read_int("Choose quality", min=1, max=len(qualities), default=1) selected_quality = qualities[no - 1] url = selected_quality["sourceURL"] url_path = urlparse(url).path extension = Path(url_path).suffix filename = "{}_{}{}".format( clip["broadcaster"]["login"], utils.slugify(clip["title"]), extension ) print("Downloading clip...") download_file(url, filename) print("Downloaded: {}".format(filename))
def _download_clip(slug, args): print_out("<dim>Looking up clip...</dim>") clip = twitch.get_clip(slug) if not clip: raise ConsoleError("Clip '{}' not found".format(slug)) print_out( "Found: <green>{}</green> by <yellow>{}</yellow>, playing <blue>{}</blue> ({})" .format(clip["title"], clip["broadcaster"]["displayName"], clip["game"]["name"], utils.format_duration(clip["durationSeconds"]))) target = _clip_target_filename(clip, args) print_out("Target: <blue>{}</blue>".format(target)) if not args.overwrite and path.exists(target): response = input("File exists. Overwrite? [Y/n]: ") if response.lower().strip() not in ["", "y"]: raise ConsoleError("Aborted") args.overwrite = True url = get_clip_authenticated_url(slug, args.quality) print_out("<dim>Selected URL: {}</dim>".format(url)) print_out("<dim>Downloading clip...</dim>") download_file(url, target) print_out("Downloaded: <blue>{}</blue>".format(target))
def test_get_clips(): """ This test depends on the channel having some videos published. """ clips = twitch.get_channel_clips(TEST_CHANNEL, "all_time", 3) assert clips["pageInfo"] assert len(clips["edges"]) > 0 clip_slug = clips["edges"][0]["node"]["slug"] clip = twitch.get_clip(clip_slug) assert clip["slug"] == clip_slug
def _download_clip(slug, args): print_out("<dim>Looking up clip...</dim>") clip = twitch.get_clip(slug) if not clip: raise ConsoleError("Clip '{}' not found".format(slug)) print_out( "Found: <green>{}</green> by <yellow>{}</yellow>, playing <blue>{}</blue> ({})" .format(clip["title"], clip["broadcaster"]["displayName"], clip["game"]["name"], utils.format_duration(clip["durationSeconds"]))) url = _get_clip_url(clip, args) print_out("<dim>Selected URL: {}</dim>".format(url)) target = _clip_target_filename(clip) print_out("Downloading clip...") download_file(url, target) print_out("Downloaded: {}".format(target))
def info(args): video_id = utils.parse_video_identifier(args.identifier) if video_id: print_log("Fetching video...") video = twitch.get_video(video_id) if not video: raise ConsoleError("Video {} not found".format(video_id)) print_log("Fetching access token...") access_token = twitch.get_access_token(video_id) print_log("Fetching playlists...") playlists = twitch.get_playlists(video_id, access_token) if video: if args.json: video_json(video, playlists) else: video_info(video, playlists) return clip_slug = utils.parse_clip_identifier(args.identifier) if clip_slug: print_log("Fetching clip...") clip = twitch.get_clip(clip_slug) if not clip: raise ConsoleError("Clip {} not found".format(clip_slug)) if args.json: print_json(clip) else: clip_info(clip) return raise ConsoleError("Invalid input: {}".format(args.video))