Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def save(settings, path):
cst = setup_cast(settings["device"], prep="control")
if not cst.save_capability or cst.is_streaming_local_file:
raise CliError("Saving state of this kind of content is not supported")
elif cst.save_capability == "partial":
warning("Please be advised that playlist data will not be saved")
print_status(cst.media_info)
if path and path.is_file():
click.confirm("File already exists. Overwrite?", abort=True)
click.echo("Saving...")
if path:
state = CastState(path, StateMode.ARBI)
cc_name = "*"
else:
state = CastState(STATE_PATH, StateMode.CONF)
cc_name = cst.cc_name
state.set_data(cc_name, {"controller": cst.name, "data": cst.media_info})
if strict:
raise AppSelectionError("App not found (strict is set)")
else:
return DEFAULT_APP
if app.name == "default":
return app
if not cast_type:
raise AppSelectionError("Cast type is needed for app selection")
elif cast_type not in app.supported_device_types:
msg = "The {} app is not available for this device".format(app.name.capitalize())
if strict:
raise AppSelectionError("{} (strict is set)".format(msg))
elif show_warning:
warning(msg)
return DEFAULT_APP
else:
return app
if stream.is_local_file:
fail_if_no_ip(stream.local_ip)
st_thr = create_server_thread(
video_url, stream.local_ip, stream.port, stream.guessed_content_type, single_req=media_is_image
)
elif stream.is_playlist and not (no_playlist and stream.video_id):
if stream.playlist_length == 0:
cst.kill(idle_only=True)
raise CliError("Playlist is empty")
if not random_play and cst.playlist_capability and stream.playlist_all_ids:
playlist_playback = True
else:
if random_play:
entry = random.randrange(0, stream.playlist_length)
else:
warning("Playlist playback not possible, playing first video")
entry = 0
stream.set_playlist_entry(entry)
if playlist_playback:
click.echo("Casting remote playlist {}...".format(video_url))
video_id = stream.video_id or stream.playlist_all_ids[0]
cst.play_playlist(stream.playlist_id, video_id=video_id)
else:
if not subtitles and not no_subs and stream.is_local_file:
subtitles = hunt_subtitles(video_url)
if subtitles:
fail_if_no_ip(stream.local_ip)
subs = SubsInfo(subtitles, stream.local_ip, stream.port + 1)
su_thr = create_server_thread(
subs.file, subs.local_ip, subs.port, "text/vtt;charset=utf-8", single_req=True
)