1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
--- src/mythtv/programs/scripts/metadata/Movie/tmdb3.py.orig 2019-06-12 14:43:30.593862061 +0000
+++ src/mythtv/programs/scripts/metadata/Movie/tmdb3.py 2019-06-12 14:55:34.110317249 +0000
@@ -30,6 +30,7 @@
from optparse import OptionParser
import sys
import signal
+import re
def timeouthandler(signal, frame):
raise RuntimeError("Timed out")
@@ -126,11 +127,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'],
|