19 __title__ =
"TheMovieDB.org for TV V3"
20 __author__ =
"Peter Bennett"
22 from optparse
import OptionParser
32 print (
"Failed to import MythTV bindings. Check your `configure` output "
33 "to make sure installation was not disabled due to external "
39 print (
"Failed to import PyTMDB3 library. This should have been included "
40 "with the python MythTV bindings.")
45 print (
"Failed to import python lxml library.")
48 print (
"Everything appears in order.")
51 def main(showType, command):
53 parser = OptionParser()
55 parser.add_option(
'-v',
"--version", action=
"store_true", default=
False,
56 dest=
"version", help=
"Display version and author")
57 parser.add_option(
'-t',
"--test", action=
"store_true", default=
False,
58 dest=
"test", help=
"Perform self-test for dependencies.")
59 parser.add_option(
'-M',
"--movielist",
"--list", action=
"store_true", default=
False,
61 help=
"Get Movies. Needs search key.")
62 parser.add_option(
'-D',
"--moviedata",
"--data", action=
"store_true", default=
False,
63 dest=
"moviedata", help=
"Get Movie data. " \
65 parser.add_option(
'-C',
"--collection", action=
"store_true", default=
False,
66 dest=
"collectiondata", help=
"Get Collection data.")
67 parser.add_option(
'-l',
"--language", metavar=
"LANGUAGE", default=
'en',
68 dest=
"language", help=
"Specify language for filtering.")
69 parser.add_option(
'-a',
"--area", metavar=
"COUNTRY", default=
None,
70 dest=
"country", help=
"Specify country for custom data.")
71 parser.add_option(
'--debug', action=
"store_true", default=
False,
72 dest=
"debug", help=(
"Disable caching and enable raw "
75 opts, args = parser.parse_args()
77 from MythTV.tmdb3.lookup
import timeouthandler
78 signal.signal(signal.SIGALRM, timeouthandler)
84 from MythTV.tmdb3
import set_key, set_cache, set_locale
85 set_key(
'c27cb71cff5bd76e1a7a009380562c62')
89 MythTV.tmdb3.request.DEBUG =
True
90 set_cache(engine=
'null')
93 confdir = os.environ.get(
'MYTHCONFDIR',
'')
94 if (
not confdir)
or (confdir ==
'/'):
95 confdir = os.environ.get(
'HOME',
'')
96 if (
not confdir)
or (confdir ==
'/'):
97 print (
"Unable to find MythTV directory for metadata cache.")
99 confdir = os.path.join(confdir,
'.mythtv')
100 cachedir = os.path.join(confdir,
'cache')
101 if not os.path.exists(cachedir):
102 os.makedirs(cachedir)
103 cachepath = os.path.join(cachedir,
'pytmdb3.cache')
104 set_cache(engine=
'file', filename=cachepath)
107 set_locale(language=opts.language, fallthrough=
True)
109 set_locale(country=opts.country, fallthrough=
True)
111 if (
not opts.version):
112 if (len(args) < 1)
or (args[0] ==
''):
113 sys.stdout.write(
'ERROR: tmdb3.py requires at least one non-empty argument.\n')
116 from MythTV.tmdb3.lookup
import buildVersion, buildMovieList, \
117 buildSingle, buildCollection, print_etree
124 xml = buildMovieList(args[0], opts)
129 elif opts.collectiondata:
133 if isinstance(xml,int):
141 except RuntimeError
as exc:
142 sys.stdout.write(
'ERROR: ' + str(exc) +
' exception')
144 traceback.print_exc()
149 if __name__ ==
'__main__':
150 sys.exit(
main(
"movie",
'tmdb3.py'))