|
@@ -27,15 +27,13 @@ from lib_stov import stov_exceptions
|
|
|
LOGGER = logging.getLogger("stov")
|
|
|
|
|
|
|
|
|
-def get_ids(conf, url, title="", reverse=False):
|
|
|
+def get_ids(conf, url, reverse=False):
|
|
|
"""
|
|
|
Retrieves the IDs
|
|
|
:param conf: configuration object
|
|
|
:type conf: lib_stov.configuration.Conf
|
|
|
:param url: URL to pass to youtube-dl
|
|
|
:type url: str
|
|
|
- :param title: optional title to match
|
|
|
- :type title: str
|
|
|
:param reverse: look up a playlist in reverse order to get \
|
|
|
the recent videos first
|
|
|
:type reverse: bool
|
|
@@ -47,35 +45,22 @@ def get_ids(conf, url, title="", reverse=False):
|
|
|
stderr = sys.stderr
|
|
|
else:
|
|
|
stderr = open("/dev/null", "w")
|
|
|
- if title:
|
|
|
- LOGGER.debug(_("Executing command: %s %s %s %s %s %s %s"),
|
|
|
- conf.values["youtube-dl"], "--max-downloads",
|
|
|
- conf.values["maxvideos"], "--match-title",
|
|
|
- title, "--get-id", url)
|
|
|
- try:
|
|
|
+ LOGGER.debug(_("Executing command: %s %s %s %s %s %s"),
|
|
|
+ conf.values["youtube-dl"], "--max-downloads",
|
|
|
+ conf.values["maxvideos"], "-i", "--get-id", url)
|
|
|
+ try:
|
|
|
+ if reverse:
|
|
|
video_ids = subprocess.check_output(
|
|
|
[conf.values["youtube-dl"], "--max-downloads",
|
|
|
- conf.values["maxvideos"], "--match-title",
|
|
|
- title, "-i", "--get-id", url], stderr=stderr)
|
|
|
- except subprocess.CalledProcessError as error_message:
|
|
|
- video_ids = error_message.output
|
|
|
- else:
|
|
|
- LOGGER.debug(_("Executing command: %s %s %s %s %s %s"),
|
|
|
- conf.values["youtube-dl"], "--max-downloads",
|
|
|
- conf.values["maxvideos"], "-i", "--get-id", url)
|
|
|
- try:
|
|
|
- if reverse:
|
|
|
- video_ids = subprocess.check_output(
|
|
|
- [conf.values["youtube-dl"], "--max-downloads",
|
|
|
- conf.values["maxvideos"], "-i", "--playlist-reverse",
|
|
|
- "--get-id", url], stderr=stderr)
|
|
|
- else:
|
|
|
- video_ids = subprocess.check_output(
|
|
|
- [conf.values["youtube-dl"], "--max-downloads",
|
|
|
- conf.values["maxvideos"],
|
|
|
- "-i", "--get-id", url], stderr=stderr)
|
|
|
- except subprocess.CalledProcessError as error_message:
|
|
|
- video_ids = error_message.output
|
|
|
+ conf.values["maxvideos"], "-i", "--playlist-reverse",
|
|
|
+ "--get-id", url], stderr=stderr)
|
|
|
+ else:
|
|
|
+ video_ids = subprocess.check_output(
|
|
|
+ [conf.values["youtube-dl"], "--max-downloads",
|
|
|
+ conf.values["maxvideos"],
|
|
|
+ "-i", "--get-id", url], stderr=stderr)
|
|
|
+ except subprocess.CalledProcessError as error_message:
|
|
|
+ video_ids = error_message.output
|
|
|
video_ids = video_ids.decode(sys.stdout.encoding).strip()
|
|
|
for video in video_ids.split("\n"):
|
|
|
videos_list.append(video)
|