Browse Source

remove itag value and use configuration video parameters instead

Helmut Pozimski 3 years ago
parent
commit
3f95d11283
3 changed files with 12 additions and 14 deletions
  1. 2 4
      lib_stov/generic_video.py
  2. 1 3
      lib_stov/subscription.py
  3. 9 7
      lib_stov/youtubedl_wrapper.py

+ 2 - 4
lib_stov/generic_video.py

@@ -40,14 +40,12 @@ class Video(object):
         self.downloaded = downloaded
         self.failcnt = int(failcount)
 
-    def download_video(self, directory, itag_value, url):
+    def download_video(self, directory, url):
         """
         Downloads the video by calling youtube-dl as an external process"
 
         :param directory: directory to download to
         :type directory: str
-        :param itag_value: quality specifier
-        :type itag_value: int
         :param video_codec: video codec to download
         :type video_codec: str
         :param url: url to the video
@@ -66,7 +64,7 @@ class Video(object):
         os.chdir(targetdir)
         if self.downloaded == 0:
             try:
-                youtubedl_wrapper.download_video(url, itag_value)
+                youtubedl_wrapper.download_video(url)
             except stov_exceptions.YoutubeDlCallFailed:
                 self.failcnt = int(self.failcnt) + 1
                 return False

+ 1 - 3
lib_stov/subscription.py

@@ -107,13 +107,11 @@ class Sub(object):
 
         """
         if not self.disabled:
-            itag_value = self._connector.get_quality_parameter(self._conf)
             for video in self._video_list:
                 if video.downloaded == 0:
                     video_url = self._connector.construct_video_url(
                         video.site_id)
-                    if video.download_video(self._directory, itag_value,
-                                            video_url):
+                    if video.download_video(self._directory, video_url):
                         self.downloaded_videos.append(video)
                     else:
                         self.failed_videos_count += 1

+ 9 - 7
lib_stov/youtubedl_wrapper.py

@@ -89,33 +89,35 @@ def get_title(url):
     return video_title
 
 
-def download_video(url, itag_value):
+def download_video(url):
     """
     Downloads a video from a specified url using youtube-dl.
 
-    :param itag_value: video and audio parameter
-    :type itag_value: str
     :param url: URL to pass to youtube-dl
     :type url: str
     """
     conf = configuration.Conf.get_instance()
     try:
+        youtube_dl_format = "%s[height=%s]+%s" % \
+                            (conf.get_value("video_codec"),
+                             conf.get_value("video_height"),
+                             conf.get_value("audio_quality"))
         LOGGER.debug(_("Executing command: %s -f %s %s"),
-                     conf.values["youtube-dl"], itag_value, url)
+                     conf.values["youtube-dl"], youtube_dl_format, url)
         if conf.outputlevel == "default":
             subprocess.check_call([conf.values["youtube-dl"], "-f %s"
-                                   % itag_value,
+                                   % youtube_dl_format,
                                    "-o", "%(title)s-%(id)s.%(ext)s", url],
                                   stderr=sys.stderr,
                                   stdout=open("/dev/null", "w"))
         elif conf.outputlevel == "verbose":
             subprocess.check_call([conf.values["youtube-dl"], "-f %s"
-                                   % itag_value,
+                                   % youtube_dl_format,
                                    "-o", "%(title)s-%(id)s.%(ext)s", url],
                                   stderr=sys.stderr, stdout=sys.stdout)
         elif conf.outputlevel == "quiet":
             subprocess.check_call([conf.values["youtube-dl"],
-                                   "-f %s/%s" % itag_value,
+                                   "-f %s" % youtube_dl_format,
                                    "-o", "%(title)s-%(id)s.%(ext)s", url],
                                   stderr=open("/dev/null", "w"),
                                   stdout=open("/dev/null", "w"))