From 397b3fb37521c10de3694a3f98ac52770c55f13f Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 23 Jan 2018 14:49:20 +0000
Subject: mythtv & mythplugins: change TMDB patch

---
 abs/core/mythtv/stable-29/mythplugins/PKGBUILD     |  2 +-
 ...TMDB-script-to-detect-movie-release-years.patch | 52 ----------------------
 abs/core/mythtv/stable-29/mythtv/PKGBUILD          |  6 +--
 ...TMDB-script-to-detect-movie-release-years.patch | 39 ++++++++++++++++
 4 files changed, 43 insertions(+), 56 deletions(-)
 delete mode 100644 abs/core/mythtv/stable-29/mythtv/0037-pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch
 create mode 100644 abs/core/mythtv/stable-29/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch

diff --git a/abs/core/mythtv/stable-29/mythplugins/PKGBUILD b/abs/core/mythtv/stable-29/mythplugins/PKGBUILD
index a6132b3..feb9259 100644
--- a/abs/core/mythtv/stable-29/mythplugins/PKGBUILD
+++ b/abs/core/mythtv/stable-29/mythplugins/PKGBUILD
@@ -9,7 +9,7 @@ pkgname=('mytharchive'
          'mythweather'
          'mythzoneminder')
 pkgver=29
-pkgrel=9
+pkgrel=10
 arch=('i686' 'x86_64')
 url="http://www.mythtv.org"
 license=('GPL')
diff --git a/abs/core/mythtv/stable-29/mythtv/0037-pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch b/abs/core/mythtv/stable-29/mythtv/0037-pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch
deleted file mode 100644
index 597b064..0000000
--- a/abs/core/mythtv/stable-29/mythtv/0037-pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-diff -Naur mythtv-master-20170223-ga8b2fe8-old/mythtv/libs/libmythmetadata/videometadata.cpp mythtv-master-20170223-ga8b2fe8-new/mythtv/libs/libmythmetadata/videometadata.cpp
---- mythtv-master-20170223-ga8b2fe8-old/mythtv/libs/libmythmetadata/videometadata.cpp	2017-02-23 13:18:09.000000000 +0100
-+++ src/mythtv/libs/libmythmetadata/videometadata.cpp	2017-02-25 14:03:16.933333314 +0100
-@@ -1162,7 +1162,7 @@
-                      title.lastIndexOf('/') -1);
- 
-         title = eatBraces(title, "[", "]");
--        title = eatBraces(title, "(", ")");
-+        //title = eatBraces(title, "(", ")");
-         title = eatBraces(title, "{", "}");
-         return title.trimmed();
-     }
-diff -Naur mythtv-master-20170223-ga8b2fe8-old/mythtv/programs/scripts/metadata/Movie/tmdb3.py mythtv-master-20170223-ga8b2fe8-new/mythtv/programs/scripts/metadata/Movie/tmdb3.py
---- mythtv-master-20170223-ga8b2fe8-old/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'],
diff --git a/abs/core/mythtv/stable-29/mythtv/PKGBUILD b/abs/core/mythtv/stable-29/mythtv/PKGBUILD
index cdac547..23bb402 100644
--- a/abs/core/mythtv/stable-29/mythtv/PKGBUILD
+++ b/abs/core/mythtv/stable-29/mythtv/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=mythtv
 pkgver=29
-pkgrel=9
+pkgrel=10
 commit_hash=`cat ../git_src/git_hash`
 pkgdesc="A Homebrew PVR project $commit_hash"
 arch=('i686' 'x86_64')
@@ -33,8 +33,8 @@ patches=(
          'defaultThemeLinHES.patch'
          'addEnableDisableAutoShutdownToSystemMenu.patch'
          'mythfrontend_en_us.ts_Title_Case.patch'
+         'pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch'
          '0006-cardutil_show_displayname.patch'
-         '0037-pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch'
          '0292-UPnP-Reduce-startup-latency-by-moving-blocking-code-to-own-thread.patch'
          '0294-0283-FE-Add-network-status-to-machine-status-dialog.patch'
          '0287-MythUiImage-Don-t-block-UI-when-exiting-screens.patch'
@@ -133,8 +133,8 @@ md5sums=('fb5a87c52a31168a0c8fdde72f27cc45'
          'b0b238320fa78a4928dce2cea7c85071'
          '8e4492d1777234a021f368bd6ee964ee'
          '1164214d9eb41588f8eb3382565cb003'
+         'd05eaf66c434a131c8efb4d87e99b402'
          '5f2bd4065b145b7b7ff09dfd6f08276c'
-         '2371cf6e680179c067a6ff7756638128'
          '1f0dbd44f8c1a89b86bb331086f58578'
          'abaef221b00690b329f4dca18676bcd6'
          '3cccbab70c7615bc47e51790e024d5bf'
diff --git a/abs/core/mythtv/stable-29/mythtv/pull103-Add-heuristic-in-TMDB-script-to-detect-movie-release-years.patch b/abs/core/mythtv/stable-29/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-29/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'],
-- 
cgit v0.12