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 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'],
|