Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def restore(settings, path):
if not path and not STATE_PATH.is_file():
raise CliError("Save file in config dir has not been created")
cst = setup_cast(settings["device"])
state = CastState(path or STATE_PATH, StateMode.READ)
try:
data = state.get_data(cst.cc_name if not path else None)
except StateFileError:
raise CliError("The chosen file is not a valid save file")
if not data:
raise CliError("No save data found for this device")
print_status(data["data"])
click.echo("Restoring...")
cst = setup_cast(settings["device"], prep="app", controller=data["controller"])
cst.restore(data["data"])
def pause(settings):
cst = setup_cast(settings["device"], action="pause", prep="control")
cst.pause()
def volumedown(settings, delta):
cst = setup_cast(settings["device"])
cst.volumedown(delta / 100.0)
def cast(settings, video_url, subtitles, force_default, random_play, no_subs, no_playlist, ytdl_option):
controller = "default" if force_default or ytdl_option else None
playlist_playback = False
st_thr = su_thr = subs = None
cst, stream = setup_cast(
settings["device"], video_url=video_url, prep="app", controller=controller, ytdl_options=ytdl_option
)
media_is_image = stream.guessed_content_category == "image"
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:
def ffwd(settings, timedesc):
cst = setup_cast(settings["device"], action="ffwd", prep="control")
cst.ffwd(timedesc)
def restore(settings, path):
if not path and not STATE_PATH.is_file():
raise CliError("Save file in config dir has not been created")
cst = setup_cast(settings["device"])
state = CastState(path or STATE_PATH, StateMode.READ)
try:
data = state.get_data(cst.cc_name if not path else None)
except StateFileError:
raise CliError("The chosen file is not a valid save file")
if not data:
raise CliError("No save data found for this device")
print_status(data["data"])
click.echo("Restoring...")
cst = setup_cast(settings["device"], prep="app", controller=data["controller"])
cst.restore(data["data"])
def add(settings, video_url, play_next):
cst, stream = setup_cast(settings["device"], video_url=video_url, action="add", prep="control")
if cst.name != stream.extractor or not (stream.is_remote_file or stream.is_playlist_with_active_entry):
raise CliError("This url cannot be added to the queue")
click.echo('Adding video id "{}" to the queue.'.format(stream.video_id))
if play_next:
cst.add_next(stream.video_id)
else:
cst.add(stream.video_id)
def seek(settings, timedesc):
cst = setup_cast(settings["device"], action="seek", prep="control")
cst.seek(timedesc)
def rewind(settings, timedesc):
cst = setup_cast(settings["device"], action="rewind", prep="control")
cst.rewind(timedesc)
def status(settings):
cst = setup_cast(settings["device"], prep="info")
print_status(cst.cast_info)