[mythtv-users] Changes to tmdb? Video details lookup failing.

Joseph Fry joe at thefrys.com
Fri Sep 27 23:41:50 UTC 2013


> I am not assuming anything.  I'm simply saying that if the end or the
> title provided to the tmdb3.py script happens to be a numeric value
> between 1900 and the current year... treat it as the release year.
>
> Here is the patch I just finished... works like a treat for me (my
> files are all named like the.croods.2013):
>
> ----------------------
>
> --- tmdb3.py.bak 2013-09-21 19:58:11.000000000 -0400
> +++ tmdb3.py 2013-09-27 18:52:47.086461718 -0400
> @@ -110,7 +110,19 @@
>      from MythTV.tmdb3 import searchMovie
>      from MythTV import VideoMetadata
>      from lxml import etree
> -    results = searchMovie(query)
> +    from datetime import date
> +
> +    if len(query.split()) > 1:
> +        title = query.rsplit(' ', 1)[0]
> +        titleyear = query.rsplit(' ', 1)[1]
> +        if titleyear.isdigit() and int(titleyear) > 1900 and \
> +           int(titleyear) < int(date.today().year + 1):
> +            results = searchMovie(title, year=titleyear)
> +        else:
> +            results = searchMovie(query)
> +    else:
> +        results = searchMovie(query)
> +
>      tree = etree.XML(u'<metadata></metadata>')
>      mapping = [['runtime',      'runtime'],     ['title',
> 'originaltitle'],
>                 ['releasedate',  'releasedate'], ['tagline',     'tagline'],
>
> -------------------------------------------
>
> Of course, this does not work if you put the year in parenthesis as
> mythtv discards this information when calling tmdb3.py.

Please excuse any unusual practices, I am not a developer by any sense
of the word.

Also, my files are named like "the.croods.2013.mkv" (I forgot the
extension above).  But mythtv only sends "the croods 2013" to the
script.

As you can see, it only uses the year if:
There is more than one 'word' in the title.
The the last 'word' is a numeric value between 1900 and the current year.

if you use the same naming convention I do... the only movie I can
imagine this failing on is one with a four digit year as the last word
of the title at which point this patch may be more appropriate, though
it results in an extra hit against tmdb.

Updated patch tested against several of the most popular movies on
tmdb with dates at the end of the title (eg class of 1999, death race
2000, airport 1975, and 2010):

-----------------
@@ -110,7 +110,21 @@
     from MythTV.tmdb3 import searchMovie
     from MythTV import VideoMetadata
     from lxml import etree
-    results = searchMovie(query)
+    from datetime import date
+
+    if len(query.split()) > 1:
+        title = query.rsplit(' ', 1)[0]
+        titleyear = query.rsplit(' ', 1)[1]
+        if titleyear.isdigit() and int(titleyear) > 1900 and \
+           int(titleyear) < int(date.today().year + 1):
+            results = searchMovie(title, year=titleyear)
+            if not results:
+                results = searchMovie(query)
+        else:
+            results = searchMovie(query)
+    else:
+        results = searchMovie(query)
+
     tree = etree.XML(u'<metadata></metadata>')
     mapping = [['runtime',      'runtime'],     ['title',
'originaltitle'],
                ['releasedate',  'releasedate'], ['tagline',     'tagline'],
--------------

I am not saying this is the BEST solution.  But it is the only
solution within my limited abilities.  Additionally, it doesn't
require renaming my entire video collection.

A better solution might be to parse dates out of parenthises in the
filename, and have mythtv supply that as a parameter to tmdb3.py which
will then forward it on to the seachMovie function... but that would
have required a patch against mythtv itself and is beyond my
abilities.

NOTE I am running the latest nightly of 0.26, I am not sure if
tmdb3.py is different in 0.27 or not.


More information about the mythtv-users mailing list