Quellcode durchsuchen

Fix situation when all videos fail and the output would have suggested there were no videos to be downloaded

Helmut Pozimski vor 11 Jahren
Ursprung
Commit
051f3b9328
3 geänderte Dateien mit 14 neuen und 8 gelöschten Zeilen
  1. 0 1
      TODO
  2. 8 5
      stov.py
  3. 6 2
      subscription.py

+ 0 - 1
TODO

@@ -10,6 +10,5 @@ Long term goals:
 * Improve handling of situations where a video is permanently unavailable
 * Add verbose output
 * Make youtube-dl output depend on output level
-* "No videos to be downloaded" shouldn't be displayed if all videos fail
 * Add option to clean database of old entries 
 * Fix Bugs that lead to double subscription entries

+ 8 - 5
stov.py

@@ -359,12 +359,14 @@ FROM subscriptions")
 		title=element[1], type=element[2], name=element[3],
 		search=element[4], directory=element[5], conf=conf))
 	videosdownloaded = 0
+	videosfailed = 0
 	for element in listofsubscriptions:
 		element.GetVideos()
 		element.DownloadVideos()
 		for entry in element.DownloadedVideos:
 			mailcontent.append(entry)
 		videosdownloaded = len(mailcontent)
+		videosfailed = videosfailed + element.FailedVideos
 	if videosdownloaded > 0 and conf.values["notify"] == "yes":
 		MailText = u""
 		msg = MIMEMultipart()
@@ -415,14 +417,15 @@ FROM subscriptions")
 						"please check your settings"), outputlevel="default",
 						level=conf.outputlevel, descriptor="stderr")
 		serverconnection.quit()
-	elif videosdownloaded == 0:
+	elif videosdownloaded == 0 and videosfailed == 0:
 		printf(_("No videos to be downloaded."), outputlevel="default",
 			level=conf.outputlevel, descriptor="stdout")
 	elif conf.values["notify"] == "no":
-		printf(_("The following videos have been downloaded:\n"),
-		outputlevel="default", level=conf.outputlevel, descriptor="stdout")
-		for i in mailcontent:
-			printf(i, outputlevel="default", level=conf.outputlevel, descriptor="stdout")
+		if videosfailed == 0:
+			printf(_("The following videos have been downloaded:\n"),
+			outputlevel="default", level=conf.outputlevel, descriptor="stdout")
+			for i in mailcontent:
+				printf(i, outputlevel="default", level=conf.outputlevel, descriptor="stdout")
 	else:
 		printf(_("Could not determine how you want to be informed"
 					"about new videos, please check the notify parameter"

+ 6 - 2
subscription.py

@@ -38,6 +38,7 @@ class sub(object):
 		self.__APIURL = ""
 		self.__conf = conf
 		self.DownloadedVideos = []
+		self.FailedVideos = 0
 
 		if self.__name != "delete":
 			self.__ConstructAPIURL()
@@ -132,8 +133,11 @@ class sub(object):
 
 		"""
 		for video in self.__videos:
-			if video.DownloadVideo(self.__directory) is True:
-				self.DownloadedVideos.append(video.title)
+			if video.downloaded == 0:
+				if video.DownloadVideo(self.__directory) is True:
+					self.DownloadedVideos.append(video.title)
+				else:
+					self.FailedVideos = self.FailedVideos + 1
 
 	"""Prints a list of all videos contained in the subscription"""
 	def PrintVideos(self):