Bläddra i källkod

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

Helmut Pozimski 11 år sedan
förälder
incheckning
da6a1a33a7
9 ändrade filer med 108 tillägg och 73 borttagningar
  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
 ----
 * 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
 MAXFAILS: Number of times the download of a video may fail until it is marked as failed
 	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 ===
 
-Currently none, contact me if you find some.
+Currently none, contact me if you find any.
 
 === INSTALLATION ===
 

+ 0 - 1
TODO

@@ -3,4 +3,3 @@ TODOs for 0.4:
 *Rework and correct strings
 *Make the whole help screen translateable
 *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": "",
 				"youtube-dl": "",
 				"notify": "yes",
-				"config_version": "6",
+				"config_version": "7",
 				"db_version": "2",
 				"videocodec": "h264",
 				"maxresolution": "1080p",
-				"maxfails": "50"
+				"maxfails": "50",
+				"check_title": "no"
 				}
 
 		self.__explanations = {
@@ -68,7 +69,9 @@ class conf(object):
 				"notify": _("if you want to be notified via e-mail about new videos"),
 				"videocodec": _("which video codec you prefer (h264, webm or flv)"),
 				"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.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)"
 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
 msgid "Opening configuration file"
 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"
 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
 msgid "Video %s not found in database, inserting..."
 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 ""
 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"
-"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"
 
 
-#: configuration.py:56
+#: configuration.py:57
 msgid "the name of your database file"
 msgstr ""
 
-#: configuration.py:57
+#: configuration.py:58
 msgid "the directory where downloaded videos are saved"
 msgstr ""
 
-#: configuration.py:58
+#: configuration.py:59
 msgid "the maximum number of videos to retrieve for each subscription"
 msgstr ""
 
-#: configuration.py:60
+#: configuration.py:61
 msgid "the host of your mail server"
 msgstr ""
 
-#: configuration.py:61
+#: configuration.py:62
 msgid "the address used for notifications"
 msgstr ""
 
-#: configuration.py:62
+#: configuration.py:63
 msgid "the sender address of notification e-mails"
 msgstr ""
 
-#: configuration.py:63
+#: configuration.py:64
 msgid "the port to use on your mail server"
 msgstr ""
 
-#: configuration.py:64
+#: configuration.py:65
 msgid "if your mail server requires authentication"
 msgstr ""
 
-#: configuration.py:65
+#: configuration.py:66
 msgid "the user name used to authenticate to your mail server"
 msgstr ""
 
-#: configuration.py:66
+#: configuration.py:67
 msgid "the password used to authenticate to your mail server"
 msgstr ""
 
-#: configuration.py:67
+#: configuration.py:68
 msgid "the path to your youtube-dl installation"
 msgstr ""
 
-#: configuration.py:68
+#: configuration.py:69
 msgid "if you want to be notified via e-mail about new videos"
 msgstr ""
 
-#: configuration.py:69
+#: configuration.py:70
 msgid "which video codec you prefer (h264, webm or flv)"
 msgstr ""
 
-#: configuration.py:70
+#: configuration.py:71
 msgid "which resolution you prefer (360p, 480p, 720p or 1080p)"
 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"
 msgstr ""
 
-#: configuration.py:87
+#: configuration.py:90
 msgid "Configuration could not be written, please check that the configuration directory exists and is writable"
 msgstr ""
 
-#: configuration.py:92
+#: configuration.py:95
 msgid "Writing value for %s"
 msgstr ""
 
-#: configuration.py:102
+#: configuration.py:105
 msgid "The database could not be created, please check that the configuration directory exists and is writable"
 msgstr ""
 
-#: configuration.py:107
+#: configuration.py:110
 msgid "Creating table subscriptions"
 msgstr ""
 
-#: configuration.py:117
+#: configuration.py:120
 msgid "Creating table videos"
 msgstr ""
 
-#: configuration.py:137
+#: configuration.py:140
 msgid "Creating hidden directory in home for configuration and database"
 msgstr ""
 
-#: configuration.py:142
+#: configuration.py:145
 msgid "Configuration directory could not be created, please check that your home directory exists and is writable"
 msgstr ""
 
-#: configuration.py:146
+#: configuration.py:149
 msgid "Looking for youtube-dl file"
 msgstr ""
 
-#: configuration.py:159
+#: configuration.py:162
 msgid "Opening config file for reading"
 msgstr ""
 
-#: configuration.py:163
+#: configuration.py:166
 msgid "Configuration could not be read, please check that the configuration file exists and is readable"
 msgstr ""
 
-#: configuration.py:167
+#: configuration.py:170
 msgid "Reading line %s"
 msgstr ""
 
-#: configuration.py:180
+#: configuration.py:183
 msgid "Checking current and running configuration version"
 msgstr ""
 
-#: configuration.py:185
+#: configuration.py:188
 msgid "Invalid config version read"
 msgstr ""
 
-#: configuration.py:190
+#: configuration.py:193
 msgid "Found running version: "
 msgstr ""
 
-#: configuration.py:191 configuration.py:215
+#: configuration.py:194 configuration.py:218
 msgid "Current version: "
 msgstr ""
 
-#: configuration.py:210
+#: configuration.py:213
 msgid "Checking current and running database version."
 msgstr ""
 
-#: configuration.py:214
+#: configuration.py:217
 msgid "Found running database version: "
 msgstr ""
 
-#: configuration.py:232
+#: configuration.py:235
 msgid "The database could not be updated, please check that the configuration directory exists and is writable"
 msgstr ""
 
-#: configuration.py:252
+#: configuration.py:255
 msgid "Trying to determine the itag value for youtube-dl from your quality and codec settings"
 msgstr ""
 
-#: configuration.py:283
+#: configuration.py:286
 msgid "Found value: %s"
 msgstr ""
 
-#: configuration.py:290
+#: configuration.py:293
 msgid ""
 "This assistant will help you to perform the initial configuration of stov. \n"
 "The default value will be displayed in brackets.\n"
 "Please specify now :\n"
 msgstr ""
 
-#: configuration.py:303
+#: configuration.py:306
 msgid "Writing initial configuration according to your input, have fun!"
 msgstr ""
 
@@ -424,87 +429,91 @@ msgstr ""
 msgid "Checking if video \"%s\" exists in the database"
 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..."
 msgstr ""
 
-#: subscription.py:117
+#: subscription.py:123
 msgid "Could not access database. Please check permissions and try again."
 msgstr ""
 
-#: subscription.py:121
+#: subscription.py:127
 msgid "Getting all videos for subscription %s from database"
 msgstr ""
 
-#: subscription.py:129
+#: subscription.py:135
 msgid "Got video %s"
 msgstr ""
 
-#: subscription.py:152
+#: subscription.py:158
 msgid "Videos in subscription "
 msgstr ""
 
-#: subscription.py:156
+#: subscription.py:162
 msgid "   (pending)"
 msgstr ""
 
-#: subscription.py:159
+#: subscription.py:165
 msgid "   (downloaded)"
 msgstr ""
 
-#: subscription.py:162
+#: subscription.py:168
 msgid "   (failed)"
 msgstr ""
 
-#: subscription.py:171
+#: subscription.py:177
 msgid "Could not write to database, new subscription was NOT added! Please check permissions and try again."
 msgstr ""
 
-#: subscription.py:177
+#: subscription.py:183
 msgid "Found subscription title %s"
 msgstr ""
 
-#: subscription.py:180
+#: subscription.py:186
 msgid "Directory: %s"
 msgstr ""
 
-#: subscription.py:186
+#: subscription.py:192
 msgid "Writing subscription info into database..."
 msgstr ""
 
-#: subscription.py:196
+#: subscription.py:202
 msgid "Subscription got internal ID %s"
 msgstr ""
 
-#: subscription.py:206
+#: subscription.py:212
 msgid "Connectiong to youtube API."
 msgstr ""
 
-#: subscription.py:209
+#: subscription.py:215
 msgid "Connection established, reading data."
 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!"
 msgstr ""
 
-#: subscription.py:220
+#: subscription.py:226
 msgid "Parsing youtube API response."
 msgstr ""
 
-#: subscription.py:243
+#: subscription.py:249
 msgid "None or invalid subscription type given, please check the type option and try again"
 msgstr ""
 
-#: subscription.py:246
+#: subscription.py:252
 msgid "Constructed the following API URL: %s"
 msgstr ""
 
-#: subscription.py:262
+#: subscription.py:268
 msgid "Video %s deleted from the database!"
 msgstr ""
 
-#: subscription.py:266
+#: subscription.py:272
 msgid "Videos %s could not be deleted from the database"
 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/>.
 	""", outputlevel="default", level=conf.outputlevel, descriptor="stdout")
 elif options.version is True:
-	printf("0.3", outputlevel="default", level=conf.outputlevel,
+	printf("0.4wip", outputlevel="default", level=conf.outputlevel,
 		descriptor="stdout")
 else:
 	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,
 				outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 			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.__cursor.execute(self.__videoquery, (self.__ytid,))
 			self.__tmpid = self.__cursor.fetchall()