Bladeren bron

adapt call to youtube-dl for downloading videos to more recent versions which removed the --max-quality setting, instead use -f with the defined itag value and the video codec definition as alternative, replace h264 with mp4 according to the youtube-dl format definition

Helmut Pozimski 9 jaren geleden
bovenliggende
commit
0c9b61a707
4 gewijzigde bestanden met toevoegingen van 24 en 24 verwijderingen
  1. 1 1
      README
  2. 3 3
      lib_stov/configuration.py
  3. 3 3
      lib_stov/subscription.py
  4. 17 17
      lib_stov/youtube.py

+ 1 - 1
README

@@ -37,7 +37,7 @@ notify: Define if you want to be notified via email about new episodes of your s
 	valid values: yes or no
 db_version: Database version (Do not change!)
 config_version: Configuration version (Do not change!)
-videocodec: Video codec used for downloaded videos (valid values: h264, webm or flv)
+videocodec: Video codec used for downloaded videos (valid values: mp4, webm or flv)
 maxresolution: Maximum resolution to use for downloaded videos, please note
 	that not all codecs and resolutions might be available so a lower resolution
 	or other codec might be used in these cases

+ 3 - 3
lib_stov/configuration.py

@@ -1,4 +1,4 @@
-#   This file is part of stov, written by Helmut Pozimski 2012-2014.
+#   This file is part of stov, written by Helmut Pozimski 2012-2015.
 #
 #   stov is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ class conf(object):
             "notify": "yes",
             "config_version": "9",
             "db_version": "3",
-            "videocodec": "h264",
+            "videocodec": "mp4",
             "maxresolution": "1080p",
             "maxfails": 50,
             "check_title": "no"
@@ -212,7 +212,7 @@ class conf(object):
                 itag_value = 45
             elif self.values["maxresolution"] == "1080p":
                 itag_value = 46
-        elif self.values["videocodec"] == "h264":
+        elif self.values["videocodec"] == "mp4":
             if self.values["maxresolution"] == "360p":
                 itag_value = 18
             elif self.values["maxresolution"] == "720p":

+ 3 - 3
lib_stov/subscription.py

@@ -1,5 +1,5 @@
 #
-#   This file is part of stov, written by Helmut Pozimski 2012-2014.
+#   This file is part of stov, written by Helmut Pozimski 2012-2015.
 #
 #   stov is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -88,8 +88,8 @@ class sub(object):
         if not self.disabled:
             for video in self.__video_list:
                 if video.downloaded == 0:
-                    if video.DownloadVideo(self.__directory, itag_value) is\
-                            True:
+                    if video.DownloadVideo(self.__directory, itag_value,
+                                           self.__conf["videocodec"]):
                         self.DownloadedVideos.append(video)
                     else:
                         self.FailedVideosCount += 1

+ 17 - 17
lib_stov/youtube.py

@@ -1,17 +1,17 @@
 #
-#	This file is part of stov, written by Helmut Pozimski 2012-2013.
+#   This file is part of stov, written by Helmut Pozimski 2012-2015.
 #
-#	stov is free software: you can redistribute it and/or modify
-#	it under the terms of the GNU General Public License as published by
-#	the Free Software Foundation, version 2 of the License.
+#   stov is free software: you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation, version 2 of the License.
 #
-#	stov is distributed in the hope that it will be useful,
-#	but WITHOUT ANY WARRANTY; without even the implied warranty of
-#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#	GNU General Public License for more details.
+#   stov is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
 #
-#	You should have received a copy of the GNU General Public License
-#	along with stov.  If not, see <http://www.gnu.org/licenses/>.
+#   You should have received a copy of the GNU General Public License
+#   along with stov.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # -*- coding: utf8 -*-
@@ -36,7 +36,7 @@ class video(object):
         self.downloaded = downloaded
         self.failcnt = int(failcount)
 
-    def DownloadVideo(self, directory, itag_value):
+    def DownloadVideo(self, directory, itag_value, video_codec):
         """Downloads the video by calling youtube-dl as an external process"""
         targetdir = self.__conf.values["downloaddir"] + "/" + directory
         if os.access(targetdir, os.F_OK) is False:
@@ -49,21 +49,21 @@ class video(object):
         if self.downloaded == 0:
             try:
                 if self.__conf.outputlevel == "default":
-                    subprocess.check_call(["youtube-dl", "--max-quality=%s"
-                                          % itag_value, "-t",
+                    subprocess.check_call(["youtube-dl", "-f %s/%s"
+                                          % (itag_value, video_codec), "-t",
                                            "http://www.youtube.com/watch?v=%s"
                                            % self.ytid],
                                           stderr=sys.stderr,
                                           stdout=open("/dev/null", "w"))
                 elif self.__conf.outputlevel == "verbose":
-                    subprocess.check_call(["youtube-dl", "--max-quality=%s"
-                                          % itag_value, "-t",
+                    subprocess.check_call(["youtube-dl", "-f %s/%s"
+                                          % (itag_value, video_codec), "-t",
                                           "http://www.youtube.com/watch?v=%s"
                                            % self.ytid],
                                           stderr=sys.stderr, stdout=sys.stdout)
                 elif self.__conf.outputlevel == "quiet":
-                    subprocess.check_call(["youtube-dl", "--max-quality=%s"
-                                          % itag_value, "-t",
+                    subprocess.check_call(["youtube-dl", "-f %s/%s"
+                                          % (itag_value, video_codec), "-t",
                                           "http://www.youtube.com/watch?v=%s"
                                           % self.ytid],
                                           stderr=open("/dev/null", "w"),