Skip to content

Commit

Permalink
Relax url validation in add cmd a bit (#157)
Browse files Browse the repository at this point in the history
..so it is possible to add a video id from a mixed video/playlist url to the queue.
  • Loading branch information
theychx authored Jan 18, 2019
1 parent 63afcb2 commit 7f2b298
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion catt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def cast_site(settings, url):
@click.pass_obj
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:
if cst.name != stream.extractor or not (stream.is_remote_file or stream.is_playlist_with_active_entry):
raise CattCliError("This url cannot be added to the queue.")
click.echo('Adding video id "%s" to the queue.' % stream.video_id)
if play_next:
Expand Down
10 changes: 5 additions & 5 deletions catt/stream_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def is_playlist(self):
return not self.is_local_file and "entries" in self._preinfo

@property
def _is_playlist_with_active_entry(self):
def is_playlist_with_active_entry(self):
return self.is_playlist and self._info

@property
Expand All @@ -95,7 +95,7 @@ def video_title(self):
return Path(self._local_file).name
elif self._is_direct_link:
return self._preinfo["webpage_url_basename"].split(".")[0]
elif self.is_remote_file or self._is_playlist_with_active_entry:
elif self.is_remote_file or self.is_playlist_with_active_entry:
return self._info["title"]
else:
return None
Expand All @@ -104,18 +104,18 @@ def video_title(self):
def video_url(self):
if self.is_local_file:
return "http://%s:%s/?loaded_from_catt" % (self.local_ip, self.port)
elif self.is_remote_file or self._is_playlist_with_active_entry:
elif self.is_remote_file or self.is_playlist_with_active_entry:
return self._get_stream_url(self._info)
else:
return None

@property
def video_id(self):
return self._info["id"] if self.is_remote_file or self._is_playlist_with_active_entry else None
return self._info["id"] if self.is_remote_file or self.is_playlist_with_active_entry else None

@property
def video_thumbnail(self):
return self._info.get("thumbnail") if self.is_remote_file or self._is_playlist_with_active_entry else None
return self._info.get("thumbnail") if self.is_remote_file or self.is_playlist_with_active_entry else None

@property
def guessed_content_type(self):
Expand Down

0 comments on commit 7f2b298

Please sign in to comment.