Browse Source

Add new option to do a string comparison between video title and search string to strictly filter out unrelated results

Helmut Pozimski 11 years ago
parent
commit
da6a1a33a7
9 changed files with 108 additions and 73 deletions
  1. 5 0
      CHANGELOG
  2. 6 1
      README
  3. 0 1
      TODO
  4. 6 3
      configuration.py
  5. BIN
      locale/de/LC_MESSAGES/stov.mo
  6. 8 0
      locale/de/LC_MESSAGES/stov.po
  7. 76 67
      messages.pot
  8. 1 1
      stov.py
  9. 6 0
      subscription.py

+ 5 - 0
CHANGELOG

@@ -1,3 +1,8 @@
+0.4 (WIP)
+----
+
+* Added title checking to filter unrelated results from subscriptions with search strings
+
 0.3
 0.3
 ----
 ----
 * Added smtp authentication
 * Added smtp authentication

+ 6 - 1
README

@@ -42,10 +42,15 @@ MAXRESOLUTION: Maximum resolution to use for downloaded videos, please note
 	or other codec might be used in these cases
 	or other codec might be used in these cases
 MAXFAILS: Number of times the download of a video may fail until it is marked as failed
 MAXFAILS: Number of times the download of a video may fail until it is marked as failed
 	and won't be tried again
 	and won't be tried again
+CHECK_TITLE: Define if stov should check the title of each video in a search or channel
+	with search string subscription. This works around some deficits of the youtube
+	API which sometimes also returns video completely unrelated to your search.
+	Videos whose titles don't match the search string will be entirely ignored.
+	valid values: yes or no
 
 
 === KNOWN ISSUES ===
 === KNOWN ISSUES ===
 
 
-Currently none, contact me if you find some.
+Currently none, contact me if you find any.
 
 
 === INSTALLATION ===
 === INSTALLATION ===
 
 

+ 0 - 1
TODO

@@ -3,4 +3,3 @@ TODOs for 0.4:
 *Rework and correct strings
 *Rework and correct strings
 *Make the whole help screen translateable
 *Make the whole help screen translateable
 *Full compability with python 3
 *Full compability with python 3
-*add options to check titles of videos to cope with deficits of the youtube API

+ 6 - 3
configuration.py

@@ -45,11 +45,12 @@ class conf(object):
 				"password": "",
 				"password": "",
 				"youtube-dl": "",
 				"youtube-dl": "",
 				"notify": "yes",
 				"notify": "yes",
-				"config_version": "6",
+				"config_version": "7",
 				"db_version": "2",
 				"db_version": "2",
 				"videocodec": "h264",
 				"videocodec": "h264",
 				"maxresolution": "1080p",
 				"maxresolution": "1080p",
-				"maxfails": "50"
+				"maxfails": "50",
+				"check_title": "no"
 				}
 				}
 
 
 		self.__explanations = {
 		self.__explanations = {
@@ -68,7 +69,9 @@ class conf(object):
 				"notify": _("if you want to be notified via e-mail about new videos"),
 				"notify": _("if you want to be notified via e-mail about new videos"),
 				"videocodec": _("which video codec you prefer (h264, webm or flv)"),
 				"videocodec": _("which video codec you prefer (h264, webm or flv)"),
 				"maxresolution": _("which resolution you prefer (360p, 480p, 720p "
 				"maxresolution": _("which resolution you prefer (360p, 480p, 720p "
-					"or 1080p)")
+					"or 1080p)"),
+				"check_title": _("if you want to compare the title of a video with the "
+						"subscription search string")
 				}
 				}
 		self.dbpath = str(os.environ['HOME']) + "/.stov/" + self.values["database"]
 		self.dbpath = str(os.environ['HOME']) + "/.stov/" + self.values["database"]
 		self.outputlevel = "default"
 		self.outputlevel = "default"

BIN
locale/de/LC_MESSAGES/stov.mo


+ 8 - 0
locale/de/LC_MESSAGES/stov.po

@@ -70,6 +70,10 @@ msgstr "welchen Video-Codec du bevorzugst (h264, webm oder flv)"
 msgid "which resolution you prefer (360p, 480p, 720p or 1080p)"
 msgid "which resolution you prefer (360p, 480p, 720p or 1080p)"
 msgstr "welche Auflösung du bevorzugst (360p, 480p, 720p oder 1080p)"
 msgstr "welche Auflösung du bevorzugst (360p, 480p, 720p oder 1080p)"
 
 
+#: configuration.py:73
+msgid "if you want to compare the title of a video with the subscription search string"
+msgstr "ob der Titel jedes Videos mit dem Suchstring des entsprechenden Abonnements verglichen werden soll"
+
 #: configuration.py:83
 #: configuration.py:83
 msgid "Opening configuration file"
 msgid "Opening configuration file"
 msgstr "Öffne die Konfigurationsdatei"
 msgstr "Öffne die Konfigurationsdatei"
@@ -434,6 +438,10 @@ msgstr "Konnte nicht in die Datenbank schreiben, das neue Abonnement wurde NICHT
 msgid "Checking if video \"%s\" exists in the database"
 msgid "Checking if video \"%s\" exists in the database"
 msgstr "Überprüfe, ob video \"%s\" bereits in der Datenbank existiert"
 msgstr "Überprüfe, ob video \"%s\" bereits in der Datenbank existiert"
 
 
+#: subscription.py:94
+msgid "You have requested title checking and the title of the video does not match with the search string, ignoring it"
+msgstr "Der Titel-Abgleich ist aktiviert und der Titel des Videos passt nicht zum Such-String, es wird ignoriert"
+
 #: subscription.py:96
 #: subscription.py:96
 msgid "Video %s not found in database, inserting..."
 msgid "Video %s not found in database, inserting..."
 msgstr "Das Video %s wurde nicht in der Datenbank gefunden, füge es hinzu..."
 msgstr "Das Video %s wurde nicht in der Datenbank gefunden, füge es hinzu..."

+ 76 - 67
messages.pot

@@ -1,167 +1,172 @@
-# GNU gettext file for stov
-# Helmut Pozimski <helmut@pozimski.eu>, 2012.
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
 #
 #
 msgid ""
 msgid ""
 msgstr ""
 msgstr ""
-"Project-Id-Version: 0.3\n"
-"POT-Creation-Date: 2012-12-27 22:18+CET\n"
-"PO-Revision-Date: 2012-12-27 22:27+CET\n"
-"Last-Translator: Helmut Pozimski <helmut@pozimski.eu>\n"
-"Language-Team: None\n"
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2013-03-21 21:39+CET\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
 "MIME-Version: 1.0\n"
 "MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: ENCODING\n"
 "Generated-By: pygettext.py 1.5\n"
 "Generated-By: pygettext.py 1.5\n"
 
 
 
 
-#: configuration.py:56
+#: configuration.py:57
 msgid "the name of your database file"
 msgid "the name of your database file"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:57
+#: configuration.py:58
 msgid "the directory where downloaded videos are saved"
 msgid "the directory where downloaded videos are saved"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:58
+#: configuration.py:59
 msgid "the maximum number of videos to retrieve for each subscription"
 msgid "the maximum number of videos to retrieve for each subscription"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:60
+#: configuration.py:61
 msgid "the host of your mail server"
 msgid "the host of your mail server"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:61
+#: configuration.py:62
 msgid "the address used for notifications"
 msgid "the address used for notifications"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:62
+#: configuration.py:63
 msgid "the sender address of notification e-mails"
 msgid "the sender address of notification e-mails"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:63
+#: configuration.py:64
 msgid "the port to use on your mail server"
 msgid "the port to use on your mail server"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:64
+#: configuration.py:65
 msgid "if your mail server requires authentication"
 msgid "if your mail server requires authentication"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:65
+#: configuration.py:66
 msgid "the user name used to authenticate to your mail server"
 msgid "the user name used to authenticate to your mail server"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:66
+#: configuration.py:67
 msgid "the password used to authenticate to your mail server"
 msgid "the password used to authenticate to your mail server"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:67
+#: configuration.py:68
 msgid "the path to your youtube-dl installation"
 msgid "the path to your youtube-dl installation"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:68
+#: configuration.py:69
 msgid "if you want to be notified via e-mail about new videos"
 msgid "if you want to be notified via e-mail about new videos"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:69
+#: configuration.py:70
 msgid "which video codec you prefer (h264, webm or flv)"
 msgid "which video codec you prefer (h264, webm or flv)"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:70
+#: configuration.py:71
 msgid "which resolution you prefer (360p, 480p, 720p or 1080p)"
 msgid "which resolution you prefer (360p, 480p, 720p or 1080p)"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:83
+#: configuration.py:73
+msgid "if you want to compare the title of a video with the subscription search string"
+msgstr ""
+
+#: configuration.py:86
 msgid "Opening configuration file"
 msgid "Opening configuration file"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:87
+#: configuration.py:90
 msgid "Configuration could not be written, please check that the configuration directory exists and is writable"
 msgid "Configuration could not be written, please check that the configuration directory exists and is writable"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:92
+#: configuration.py:95
 msgid "Writing value for %s"
 msgid "Writing value for %s"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:102
+#: configuration.py:105
 msgid "The database could not be created, please check that the configuration directory exists and is writable"
 msgid "The database could not be created, please check that the configuration directory exists and is writable"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:107
+#: configuration.py:110
 msgid "Creating table subscriptions"
 msgid "Creating table subscriptions"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:117
+#: configuration.py:120
 msgid "Creating table videos"
 msgid "Creating table videos"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:137
+#: configuration.py:140
 msgid "Creating hidden directory in home for configuration and database"
 msgid "Creating hidden directory in home for configuration and database"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:142
+#: configuration.py:145
 msgid "Configuration directory could not be created, please check that your home directory exists and is writable"
 msgid "Configuration directory could not be created, please check that your home directory exists and is writable"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:146
+#: configuration.py:149
 msgid "Looking for youtube-dl file"
 msgid "Looking for youtube-dl file"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:159
+#: configuration.py:162
 msgid "Opening config file for reading"
 msgid "Opening config file for reading"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:163
+#: configuration.py:166
 msgid "Configuration could not be read, please check that the configuration file exists and is readable"
 msgid "Configuration could not be read, please check that the configuration file exists and is readable"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:167
+#: configuration.py:170
 msgid "Reading line %s"
 msgid "Reading line %s"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:180
+#: configuration.py:183
 msgid "Checking current and running configuration version"
 msgid "Checking current and running configuration version"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:185
+#: configuration.py:188
 msgid "Invalid config version read"
 msgid "Invalid config version read"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:190
+#: configuration.py:193
 msgid "Found running version: "
 msgid "Found running version: "
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:191 configuration.py:215
+#: configuration.py:194 configuration.py:218
 msgid "Current version: "
 msgid "Current version: "
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:210
+#: configuration.py:213
 msgid "Checking current and running database version."
 msgid "Checking current and running database version."
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:214
+#: configuration.py:217
 msgid "Found running database version: "
 msgid "Found running database version: "
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:232
+#: configuration.py:235
 msgid "The database could not be updated, please check that the configuration directory exists and is writable"
 msgid "The database could not be updated, please check that the configuration directory exists and is writable"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:252
+#: configuration.py:255
 msgid "Trying to determine the itag value for youtube-dl from your quality and codec settings"
 msgid "Trying to determine the itag value for youtube-dl from your quality and codec settings"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:283
+#: configuration.py:286
 msgid "Found value: %s"
 msgid "Found value: %s"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:290
+#: configuration.py:293
 msgid ""
 msgid ""
 "This assistant will help you to perform the initial configuration of stov. \n"
 "This assistant will help you to perform the initial configuration of stov. \n"
 "The default value will be displayed in brackets.\n"
 "The default value will be displayed in brackets.\n"
 "Please specify now :\n"
 "Please specify now :\n"
 msgstr ""
 msgstr ""
 
 
-#: configuration.py:303
+#: configuration.py:306
 msgid "Writing initial configuration according to your input, have fun!"
 msgid "Writing initial configuration according to your input, have fun!"
 msgstr ""
 msgstr ""
 
 
@@ -424,87 +429,91 @@ msgstr ""
 msgid "Checking if video \"%s\" exists in the database"
 msgid "Checking if video \"%s\" exists in the database"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:96
+#: subscription.py:94
+msgid "You have requested title checking and the title of the video does not match with the search string, ignoring it"
+msgstr ""
+
+#: subscription.py:102
 msgid "Video %s not found in database, inserting..."
 msgid "Video %s not found in database, inserting..."
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:117
+#: subscription.py:123
 msgid "Could not access database. Please check permissions and try again."
 msgid "Could not access database. Please check permissions and try again."
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:121
+#: subscription.py:127
 msgid "Getting all videos for subscription %s from database"
 msgid "Getting all videos for subscription %s from database"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:129
+#: subscription.py:135
 msgid "Got video %s"
 msgid "Got video %s"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:152
+#: subscription.py:158
 msgid "Videos in subscription "
 msgid "Videos in subscription "
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:156
+#: subscription.py:162
 msgid "   (pending)"
 msgid "   (pending)"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:159
+#: subscription.py:165
 msgid "   (downloaded)"
 msgid "   (downloaded)"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:162
+#: subscription.py:168
 msgid "   (failed)"
 msgid "   (failed)"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:171
+#: subscription.py:177
 msgid "Could not write to database, new subscription was NOT added! Please check permissions and try again."
 msgid "Could not write to database, new subscription was NOT added! Please check permissions and try again."
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:177
+#: subscription.py:183
 msgid "Found subscription title %s"
 msgid "Found subscription title %s"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:180
+#: subscription.py:186
 msgid "Directory: %s"
 msgid "Directory: %s"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:186
+#: subscription.py:192
 msgid "Writing subscription info into database..."
 msgid "Writing subscription info into database..."
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:196
+#: subscription.py:202
 msgid "Subscription got internal ID %s"
 msgid "Subscription got internal ID %s"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:206
+#: subscription.py:212
 msgid "Connectiong to youtube API."
 msgid "Connectiong to youtube API."
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:209
+#: subscription.py:215
 msgid "Connection established, reading data."
 msgid "Connection established, reading data."
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:214
+#: subscription.py:220
 msgid "Could not get API data, maybe the API is down or you have given wrong parameters, please check and try again!"
 msgid "Could not get API data, maybe the API is down or you have given wrong parameters, please check and try again!"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:220
+#: subscription.py:226
 msgid "Parsing youtube API response."
 msgid "Parsing youtube API response."
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:243
+#: subscription.py:249
 msgid "None or invalid subscription type given, please check the type option and try again"
 msgid "None or invalid subscription type given, please check the type option and try again"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:246
+#: subscription.py:252
 msgid "Constructed the following API URL: %s"
 msgid "Constructed the following API URL: %s"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:262
+#: subscription.py:268
 msgid "Video %s deleted from the database!"
 msgid "Video %s deleted from the database!"
 msgstr ""
 msgstr ""
 
 
-#: subscription.py:266
+#: subscription.py:272
 msgid "Videos %s could not be deleted from the database"
 msgid "Videos %s could not be deleted from the database"
 msgstr ""
 msgstr ""
 
 

+ 1 - 1
stov.py

@@ -540,7 +540,7 @@ elif options.license is True:
 	along with stov.  If not, see <http://www.gnu.org/licenses/>.
 	along with stov.  If not, see <http://www.gnu.org/licenses/>.
 	""", outputlevel="default", level=conf.outputlevel, descriptor="stdout")
 	""", outputlevel="default", level=conf.outputlevel, descriptor="stdout")
 elif options.version is True:
 elif options.version is True:
-	printf("0.3", outputlevel="default", level=conf.outputlevel,
+	printf("0.4wip", outputlevel="default", level=conf.outputlevel,
 		descriptor="stdout")
 		descriptor="stdout")
 else:
 else:
 	parser.print_help()
 	parser.print_help()

+ 6 - 0
subscription.py

@@ -89,6 +89,12 @@ class sub(object):
 			printf(_('Checking if video "%s" exists in the database') % i.title,
 			printf(_('Checking if video "%s" exists in the database') % i.title,
 				outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 				outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 			self.__ytid = i.ytid
 			self.__ytid = i.ytid
+			if self.__search != "" and self.__conf.values["check_title"] == "yes":
+				if self.__search not in i.title:
+					printf(_("You have requested title checking and the title of the video "
+						"does not match with the search string, ignoring it"),
+						outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
+					continue
 			self.__videoquery = "SELECT id FROM videos WHERE ytid=?"
 			self.__videoquery = "SELECT id FROM videos WHERE ytid=?"
 			self.__cursor.execute(self.__videoquery, (self.__ytid,))
 			self.__cursor.execute(self.__videoquery, (self.__ytid,))
 			self.__tmpid = self.__cursor.fetchall()
 			self.__tmpid = self.__cursor.fetchall()