14
14
15
15
load_dotenv ()
16
16
17
- BUILD_TEST_DATA = True
17
+ BUILD_TEST_DATA = False
18
18
API_KEY = "superscret" if not BUILD_TEST_DATA else os .getenv ("OMDB_API_KEY" , "supersecret" )
19
19
RECORD_MODE = "new_episodes" if BUILD_TEST_DATA else "none"
20
20
@@ -32,28 +32,26 @@ def __init__(self, api_key, timeout=5, strict=True):
32
32
)
33
33
34
34
def _build_path (self , kwargs ):
35
+ if "s" in kwargs :
36
+ if "type" in kwargs and kwargs ["type" ] == "series" :
37
+ return f"search/series/{ kwargs ['s' ]} "
38
+ if "type" in kwargs and kwargs ["type" ] == "movie" :
39
+ return f"search/movie/{ kwargs ['s' ]} "
40
+ return f"search/{ kwargs ['s' ]} "
41
+
42
+ val = kwargs ["t" ] if "t" in kwargs else kwargs ["i" ]
35
43
if kwargs ["apikey" ] == "123456" :
36
- val = kwargs ["t" ] if "t" in kwargs else kwargs ["i" ]
37
44
return f"exceptions/bad_api_key/{ val } "
38
45
if "t" in kwargs and kwargs ["t" ] == "Random Movie Title" :
39
- val = kwargs ["t" ] if "t" in kwargs else kwargs ["i" ]
40
46
return f"exceptions/no_results/{ val } "
41
47
if "type" in kwargs and kwargs ["type" ] == "series" :
42
- if "s" in kwargs : # searching for series
43
- return f"search/series/{ kwargs ['s' ]} "
44
- return f"series/{ kwargs ['t' ]} "
48
+ return f"series/{ val } "
45
49
if "type" in kwargs and kwargs ["type" ] == "movie" :
46
- if "s" in kwargs : # searching for series
47
- return f"search/movie/{ kwargs ['s' ]} "
48
- val = kwargs ["t" ] if "t" in kwargs else kwargs ["i" ]
49
50
return f"movie/{ val } "
50
51
if "type" in kwargs and kwargs ["type" ] == "episode" :
51
52
if "Episode" in kwargs :
52
- return f"episode/{ kwargs ['t' ]} /episode-{ kwargs ['Episode' ]} "
53
- return f"episodes/{ kwargs ['t' ]} "
54
- if "s" in kwargs :
55
- return f"search/{ kwargs ['s' ]} "
56
- # print(kwargs)
53
+ return f"episode/{ val } /episode-{ kwargs ['Episode' ]} "
54
+ return f"episodes/{ val } "
57
55
58
56
return str (kwargs )
59
57
0 commit comments