-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_all_tmdb.py
More file actions
135 lines (116 loc) · 4.91 KB
/
Copy pathget_all_tmdb.py
File metadata and controls
135 lines (116 loc) · 4.91 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python3
"""
Aggregate resolver - runs all resolvers and combines valid results into a single JSON output.
"""
import json
import argparse
import importlib
import os
import sys
import traceback
RESOLVER_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'providers')
sys.stdout.reconfigure(encoding='utf-8')
sys.path.insert(0, RESOLVER_DIR)
RESOLVERS = [
('anime.anizone', 'AniZoneResolver', 'anizone'),
('anime.hianime', 'HiAnimeResolver', 'hianime'),
('tmdb.castle', 'CastleResolver', 'castle'),
('tmdb.fsharetv', 'FshareTvResolver', 'fsharetv'),
('tmdb.hdhub', 'HdHubResolver', 'hdhub'),
('tmdb.movieblast', 'MovieBlastResolver', 'movieblast'),
('tmdb.moviesdrive', 'MoviesDriveResolver', 'moviesdrive'),
('tmdb.netmirror', 'NetMirrorResolver', 'netmirror'),
('tmdb.showbox', 'ShowBoxResolver', 'showbox'),
('tmdb.streamflix', 'StreamFlixResolver', 'streamflix'),
('tmdb.vidapi', 'VidApiResolver', 'vidapi'),
('tmdb.vidlink', 'VidlinkResolver', 'vidlink'),
('tmdb.vidnest', 'VidNestResolver', 'vidnest'),
('tmdb.vidrock', 'VidrockResolver', 'vidrock'),
('tmdb.vidzee', 'VidzeeResolver', 'vidzee'),
('tmdb.vixsrc', 'VixSrcResolver', 'vixsrc'),
]
def main():
parser = argparse.ArgumentParser(
description='Aggregate TMDB resolver - runs all TMDB/anime resolvers'
)
parser.add_argument('url_or_id', help='TMDB ID or URL')
parser.add_argument('--type', choices=['movie', 'tv'], default='movie',
help='Media type (default: movie)')
parser.add_argument('--season', type=int, help='Season number (for TV)')
parser.add_argument('--episode', type=int, help='Episode number (for TV)')
parser.add_argument('--ui-cookie', help='FebBox UI token (required for ShowBox)')
parser.add_argument('--debug', action='store_true', help='Enable debug logging')
parser.add_argument('--pretty', action='store_true', help='Pretty print JSON output')
args = parser.parse_args()
aggregated = {
'status': 'success',
'input': {
'url_or_id': args.url_or_id,
'media_type': args.type,
'season': args.season,
'episode': args.episode,
},
'resolvers': {},
'total_playable_urls': 0,
}
for module_path, class_name, resolver_key in RESOLVERS:
sys.stderr.write(f"[{resolver_key}] Running...\n")
try:
module = importlib.import_module(module_path)
ResolverClass = getattr(module, class_name)
resolver_args = {'debug': args.debug}
# Special handling: showbox needs ui-cookie in constructor
if resolver_key == 'showbox':
if not args.ui_cookie:
aggregated['resolvers'][resolver_key] = {
'status': 'skipped',
'message': '--ui-cookie required for ShowBox resolver'
}
sys.stderr.write(f"[{resolver_key}] Skipped (no --ui-cookie)\n")
continue
resolver_args['ui_cookie'] = args.ui_cookie
resolver = ResolverClass(**resolver_args)
# moviesdrive uses tmdb_id instead of url_or_id
if resolver_key == 'moviesdrive':
resolve_kwargs = {
'tmdb_id': args.url_or_id,
'media_type': args.type,
'season': args.season,
'episode': args.episode,
}
else:
resolve_kwargs = {
'url_or_id': args.url_or_id,
'media_type': args.type,
'season': args.season,
'episode': args.episode,
}
result_json = resolver.resolve(**resolve_kwargs)
result = json.loads(result_json)
aggregated['resolvers'][resolver_key] = result
playable = result.get('playable_urls', [])
if result.get('status') == 'success' and playable:
aggregated['total_playable_urls'] += len(playable)
sys.stderr.write(
f"[{resolver_key}] OK - {len(playable)} URL(s)\n"
)
else:
msg = result.get('message', 'No playable URLs')
sys.stderr.write(f"[{resolver_key}] {msg}\n")
except Exception as e:
aggregated['resolvers'][resolver_key] = {
'status': 'error',
'message': str(e),
}
if args.debug:
sys.stderr.write(
f"[{resolver_key}] Error: {e}\n"
f"{traceback.format_exc()}\n"
)
else:
sys.stderr.write(f"[{resolver_key}] Error: {e}\n")
output = json.dumps(aggregated, indent=2 if args.pretty else None, ensure_ascii=False)
print(output)
if __name__ == '__main__':
main()