فهرست منبع

Use maxvideos parameter to limit the number of videos retrieved from youtube API for each subscription

Helmut Pozimski 12 سال پیش
والد
کامیت
448b43636a
4فایلهای تغییر یافته به همراه13 افزوده شده و 8 حذف شده
  1. 6 3
      README
  2. 0 1
      TODO
  3. 1 1
      configuration.py
  4. 6 3
      subscription.py

+ 6 - 3
README

@@ -30,17 +30,20 @@ YOUTUBE-DL: Path to the youtube-dl binary if not found automatically
 DOWNLOADDIR: Path the downloaded videos are saved into
 DATABASE: File name to use for the database
 SMTPPORT: Port used to connect to the mail server
-MAXVIDEOS: Maximum number of videos to download (not used at the moment)
+MAXVIDEOS: Maximum number of videos to retrieve from the youtube API for each subscription,
+	default 25, maximum 50, reduce this parameter for better parsing performance
 NOTIFY: Define if you want to be notified via email about new episodes of your subscriptions,
 	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)
-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
+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
 
 === KNOWN ISSUES ===
 
-In some situations, adding a channel with a search parameter or a playlist will lead to two subscriptions being created
+Currently none, contact me if you find some.
 
 === INSTALLATION ===
 

+ 0 - 1
TODO

@@ -4,5 +4,4 @@ Long term goals:
 * Add full german translation
 * Add interactive configuration option
 * Add additional video sites
-* Implement maxvids option
 * Improve handling of situations where a video is permanently unavailable

+ 1 - 1
configuration.py

@@ -34,7 +34,7 @@ class conf(object):
 		self.values = {
 				"database": "stov.sqlite",
 				"downloaddir": str(os.environ['HOME']) + "/stov",
-				"maxvideos": "15",
+				"maxvideos": "25",
 				"mailhost": "localhost",
 				"mailto": "root",
 				"mailfrom": "stov@localhost",

+ 6 - 3
subscription.py

@@ -222,16 +222,19 @@ class sub(object):
 		"""Constructs the API URL which is used to retrieve API data"""
 		if self.__type == "channel":
 			self.__APIURL = "https://gdata.youtube.com/feeds/api/users/"\
-			+ urllib2.quote(self.__name) + "/uploads/" + "?v=2"
+			+ urllib2.quote(self.__name) + "/uploads/" + "?v=2"\
+			+ "&max-results=%s" % self.__conf.values["maxvideos"]
 			if self.__search != "":
 				self.__APIURL = self.__APIURL + "&q=" + "%22"\
 				+ urllib2.quote(self.__search) + "%22"
 		elif self.__type == "search":
 			self.__APIURL = "http://gdata.youtube.com/feeds/api/videos?q="\
-			+ urllib2.quote(self.__search) + "&max-results=10" + "&v=2"
+			+ urllib2.quote(self.__search) + "&v=2"\
+			+ "&max-results=%s" % self.__conf.values["maxvideos"]
 		elif self.__type == "playlist":
 			self.__APIURL = "https://gdata.youtube.com/feeds/api/playlists/"\
-			+ "%20" + urllib2.quote(self.__name) + "%20" + "?v=2"
+			+ "%20" + urllib2.quote(self.__name) + "%20" + "?v=2"\
+			+ "&max-results=%s" % self.__conf.values["maxvideos"]
 		else:
 			printf(_("None or invalid subscription type given, "
 						"please check the type option and try again"),