summaryrefslogtreecommitdiffstats
path: root/abs/core/mythtv/stable-30/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/mythtv/stable-30/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch')
-rw-r--r--abs/core/mythtv/stable-30/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch39
1 files changed, 39 insertions, 0 deletions
diff --git a/abs/core/mythtv/stable-30/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch b/abs/core/mythtv/stable-30/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch
new file mode 100644
index 0000000..2845250
--- /dev/null
+++ b/abs/core/mythtv/stable-30/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch
@@ -0,0 +1,39 @@
+--- src/mythtv/programs/scripts/metadata/Movie/tmdb3.py 2017-02-23 13:18:12.000000000 +0100
++++ src/mythtv/programs/scripts/metadata/Movie/tmdb3.py 2017-02-25 13:12:40.213333328 +0100
+@@ -29,6 +29,7 @@
+
+ from optparse import OptionParser
+ import sys
++import re
+
+ def buildSingle(inetref, opts):
+ from MythTV.tmdb3.tmdb_exceptions import TMDBRequestInvalid
+@@ -122,11 +123,27 @@
+ # replace all dashes from queries to work around search behavior
+ # as negative to all text that comes afterwards
+ query = query.replace('-',' ')
++ query = query.strip() # trim extra whitespace
++ # extract year from name -- note that we require a space before the year
++ # so we don't confuse movie names for years (example: "2012 - 2009",
++ # a 2009 movie); also note that we accept optional paranthesis around
++ # the year:
++ yearRegex = re.compile(r"\s\(?((19|20)[0-9]{2})\)?$")
++ year = yearRegex.search(query)
++ if year is not None:
++ year = year.group(1)
++ # if no year was found, we'll pass year=None to searchMovie,
++ # which is the default anyway
++
++ # get rid of the year (if any) from the query text, because
++ # it causes bad TMDB results
++ query = yearRegex.sub("", query)
++ query = query.strip()
+
+ from MythTV.tmdb3 import searchMovie
+ from MythTV import VideoMetadata
+ from lxml import etree
+- results = iter(searchMovie(query))
++ results = iter(searchMovie(query, locale=None, adult=False, year=year))
+ tree = etree.XML(u'<metadata></metadata>')
+ mapping = [['runtime', 'runtime'], ['title', 'originaltitle'],
+ ['releasedate', 'releasedate'], ['tagline', 'tagline'],