From a66e8348e6c498fb2f42ba3601253f3671eb5d17 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Mon, 19 Sep 2022 16:46:54 -0400 Subject: [PATCH] [28] add AniDB API --- VERSION | 2 +- docs/config/anidb-1.png | Bin 0 -> 10154 bytes docs/config/anidb-2.png | Bin 0 -> 5552 bytes docs/config/anidb-3.png | Bin 0 -> 8253 bytes docs/config/anidb.md | 49 +++++++++++++++++-- modules/anidb.py | 103 ++++++++++++++++++++++++++++++---------- modules/cache.py | 48 +++++++++++++++++++ modules/config.py | 9 +++- 8 files changed, 179 insertions(+), 32 deletions(-) create mode 100644 docs/config/anidb-1.png create mode 100644 docs/config/anidb-2.png create mode 100644 docs/config/anidb-3.png diff --git a/VERSION b/VERSION index 880de668..18fb59ea 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.3-develop27 +1.17.3-develop28 diff --git a/docs/config/anidb-1.png b/docs/config/anidb-1.png new file mode 100644 index 0000000000000000000000000000000000000000..8ee0c11d447c0ae801745e09cf820c2e11d20048 GIT binary patch literal 10154 zcmbVycT|(#vUco>6cG{W(xnSX51>>5>C#K21`Iv4Q0<8H4kDpRCqxJ>(xi7n@0~#C zNa!_R{GGDSUFV#2@B049%3ANdvuEa=d1m&rcZjy83K<{fQ+=+e3jkdHLi|5* z^D^(0AcMe_7)p8F3YfxA-ClXo+?^4SqJs zQ++~{7>g$~?y!-?<>F$0+1dVnx83@w=!#gP+MbVQ@bKe}g@)eur-#f*r<>ISUUvb2 zbo9+QoP0+5$KKO}&D8o=Zhu!|iT~EMbg<<_=tZdiLofm7FFP6yad82;P7ai%UM1Qk z(1<;LLn*`d$1~6C|L)lhJSovm$)S#22bx)ElgdT#&dzymf&~;)7_rUS3z9v)+94!u z(0eq))|xwrO!i(JduxS(R+^vA?Ox*W58O(n3425s)K|;jJK)+*@*BNfQl$TDXx%{5 z2NcdtjPQd;vA7u4gh%Ve&!T{dhhcYK1|O(XXlcT!d1Z(JCVknlt2#R4*^>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NYSDTh??p1~UUEXptJHNlZA^0o9eu`0mJ!BLuD2^_rRXB-z|k}q)i+xp)6pqL+R1Sys_?vBtzt#{Oj2#pRh+cM`adufhpi@S)+o@4j7(S`5c z4r4=E5VP*7ZuO?j1nGTUn7}mjOs8C=({SKp43?s>$at$(P@sN08h6F}b|QE_X;v)Z zQ}U#;`QCJh)qX0)M}9sfA{=C7nNuwW`C_0c_9O?$h%G0%q5*-a#oEGhg?P?dW`p>w zvnXb|7SW^)io!Te#$et4wfcdpVKGb{aA0tnaJfX5__WSjJ+;?{*6e2{F(Z1d{s$lA z2#)&|nmWXNvi4;pNB%!i4O`BxZ?u>V|Nn->Prxhf&*1BJ|A6~w98b~z5n)YQ@HND{ z9ybh&5w)@%ZadfXDCGPBcv8`rDSPqYyn|<`psr1IDnv`qY>oVXgz|s1q%CC7bk_N> z?5G8A`QGYaE&}1ym)BN~t2<7}QOTslJW@yh4bYRFo_-Xt{o%zjLfo#x z;c(*6Fg|X~cfSlXJj^9Y+;gAoug^|QOdvsW|3@ugOEc7qg2ERAWk%mOZ$7!K8s>$& zqjBP>mdUsDx5i>yap|vKdd;}d=+7OqhYtTrTl{Yq(*8S{^FQvP5SUNDFiI@488Z`! P5rC?ared-Dt9SnomsUo% literal 0 HcmV?d00001 diff --git a/docs/config/anidb-2.png b/docs/config/anidb-2.png new file mode 100644 index 0000000000000000000000000000000000000000..2d9afd4e83855eb48b77c0c28f252eb493226071 GIT binary patch literal 5552 zcmd5=XH-+$whka7a0oWw00Jrk3I+}!pmb@$qx2>nksbmlQiBvlP^y6Rj#30dPY@EC zAiYXYsM4e)p$9@BFPwAV8TX7g?j85f8}I$tWA8opoO7);=bGR8=6dUwf0I>NyP`hvFi@{AZ`x=ghG;evXB-+LQCSDP0=x0Q) zWcT2_uzE=%Y3f*+|KMh11byy-GRjT;jlPZZXA#T#S7synYV!}B>G}0JXw)Gh726T| zhHcyWs=80}qB_(Ena)k2; zJK%B-5|BfSpa-xOfdECyP#R@=7iNI4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jPtg)v#X!RXYp&Kb^IN@zmgUtA5jl} zk#%vhKPr5Xda4898|IhrFN|K4&Wd|txFjWjWe2bQ5>8K&R4mfxq%UB_WYnAW6MS=J r(J+=9wpc9E%l{t`_y0hJ!rDHr@M{lQaGd%l7Vtn_TdhpR=GA`zUp2p} literal 0 HcmV?d00001 diff --git a/docs/config/anidb-3.png b/docs/config/anidb-3.png new file mode 100644 index 0000000000000000000000000000000000000000..0d337930a000e1f109fb47dc5541787ac47c2e61 GIT binary patch literal 8253 zcmcI~XIN9+*6l{5C?FsrqC!-xphSvBN(d;}KoAf?DWQl+jZ&lp5=5#9s7MnbzM@DG zA}C!55)dWQM0yFKNQoq&gd`A>yYcmW_q*qQ_c`bMxctb&voqJ6bFVelm}AYAxXY&J zBsTBd3;=+{h4Y3M0I(qs00iKo8^9;$Gem9zz@Cj43=OUX4a^OTJ=!*TuYNw;iG18q zRAj5r3AG(k!RbHbx8YTd_J4j9`Tfe%NYOZR#fXDDk^6rrHYuDv|83KkGiHL(VzWkx zi?U5Y2Sub?$AdN>Qd1LvN6I|1UvB!NI?WaU&Pz2&0{RjEWh$lN*{iGT)fYUjTGyzFrIH9dB4pWKXO61cegGWb_)wIq z1_dAuRd$^p?ktI<8xOgDtVuqq%(J@E%qP=g` z^XD&k0Pxh%nre38O;^6^y&n1fTxE`eed7d@DhU7)(s6VX4Af|n%-0r-MqVL+6PpRI zy4~6Gjs<@0>dE_fEhWWDR#vujt*%$*FxU4juJxv^tu2l7>5LOy1^`-m6v$P@xw++~ zr51^+VfaJ0*iE+yMMXtb`7dxoxjJowDy|L$? zmUQblqdkjRHlG%1XG&fqity2cp0l=ciEw_RExtl;a=K*v{m&lKObTiH5?`NijKEtf zO+nlViHl;wBv+@kW{ty~II|v6zF)(zL4Lf5)lj;~T9L%=KEnROCyKVLcHail_G*G$ z*RI~+{<$U#s%BVY9qY`69zkGUcAP=-CAnL^e!ls}Eoom#0%>P)_R6sw9U^kTMU>L= zRR+)dE;~z#m{bX7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0b?D%wN4tVm>_lm`8 zHz&b{)KC}tc5RJ7Zy)Z#Bgqc6qKMJ%LV3bLt*z(DLDgL1$aBRf7hfx@s1y`>f}c(PeVKxdpGV;6CIi2K zfHG0SsqihO1zRJL4nO7Y^HP7N_Vn~5_a{5I($Fy0BGn zdzONHU>^z5{|f$JEs6+#0)ovSRKy2Bnw#Fo1ulZL+6mrwJ>3n)Ai1zba6A~SEq$S| zl@LZjR7BT)1#zmq9w3c@V|BiFYfZPXv}aCqLE)=hY!&|Y^rKIUJ_LiXs=LFVK{>!E zJunv6dx=nhp)5ogZ^i5xTTcKaB;J@9p0gk;o0SsA`hq@}q|l!It*(43fy~2LkH_7l zF63fB;Z3+TF9=fA(aHmnki+YYt;%9xf0i28opL{|?Y(F{Kd7UfP5v;M?}l}MhMHwX zaQr5gQj(#Wrzp;9C4Q_r*}~pkbOh|UA8iBEuw-K9zVH`UFYw)er$M90squP-JgFX@ zUW822B;CIHX99u-gBu~bp&EFI#9L7MtD|lm61*{k!z`ycXMpsgs2em2a(AVd21R7w z`fOP-u3&S`h7~F>e)Zv!u`_bWkV!L?BAcOgM(+-Vv$o>e_#ElY8(wL~b*2SscjF;a zv07uD{?5o_dnCo|KotB=#=(bHm|wioGvw}uW9|*`!=*1uk~94V+%w2rpI)LTY+5X{ z0fGMf)O(N>8|Q9$h$r%T3ERGz*wuClgUe4Jq$r@QcwB%+1)e4r(pEsx@BGx>Uaac;P z2$@63Cf@`-tivcC(J%I5;y(eNaU|jY!Zw)F|K1fCdacWtxk*f|me8xNnd<85F4NWU zplw}Fs4V~*v@8zQBae)XfSfUsEek$170AC*@bYCTX!-Kx>Gg2{Sl#!0U$Ac&kutMb y{{#|2ne;zjEC1_G_1cFgTx-DOF8H$m;DV8 0: parse_results = [r.strip() for r in parse_results if len(r) > 0] if parse_results: if is_list: return parse_results + elif is_dict: + return {ta.get("xml:lang"): ta.text_content() for ta in parse_results} elif is_float: return float(parse_results[0]) elif is_date: - return datetime.strptime(parse_results[0], "%d.%m.%Y") + return datetime.strptime(parse_results[0], "%Y-%m-%d") else: return parse_results[0] except (ValueError, TypeError): @@ -42,26 +54,47 @@ class AniDBObj: raise Failed(f"AniDB Error: No Anime Found for AniDB ID: {self.anidb_id}") elif is_list: return [] - elif is_float: - return 0 + elif is_dict: + return {} else: return None - self.official_title = parse_page(f"//th[text()='Main Title']/parent::tr/td/span/text()", fail=True) - self.title = parse_page(f"//th[text()='Official Title']/parent::tr/td/span/span/span[text()='{self.language}']/parent::span/parent::span/parent::td/label/text()") - self.rating = parse_page(f"//th[text()='Rating']/parent::tr/td/span/a/span/text()", is_float=True) - self.average = parse_page(f"//th[text()='Average']/parent::tr/td/span/a/span/text()", is_float=True) - self.released = parse_page(f"//th[text()='Year']/parent::tr/td/span/text()", is_date=True) - self.tags = [g.capitalize() for g in parse_page("//th/a[text()='Tags']/parent::th/parent::tr/td/span/a/span/text()", is_list=True)] - self.description = response.xpath(f"string(//div[@itemprop='description'])") + self.main_title = _parse("main_title", "//anime/titles/title[@type='main']/text()", fail=True) + self.titles = _parse("titles", "//anime/titles/title[@type='official']", is_dict=True) + self.official_title = self.titles[self._anidb.language] if self._anidb.language in self.titles else self.main_title + self.rating = _parse("rating", "//anime/ratings/permanent/text()", is_float=True) + self.average = _parse("average", "//anime/ratings/temporary/text()", is_float=True) + self.score = _parse("score", "//anime/ratings/review/text()", is_float=True) + self.released = _parse("released", "//anime/startdate/text()", is_date=True) + self.tags = _parse("tags", "//anime/tags/tag[@infobox='true']/name/text()", is_list=True) class AniDB: - def __init__(self, config, language): + def __init__(self, config, data): self.config = config - self.language = language + self.language = data["language"] + self.expiration = 60 + self.client = None + self.version = None self.username = None self.password = None + self._delay = None + + def authorize(self, client, version, expiration): + self.client = client + self.version = version + logger.secret(self.client) + self.expiration = expiration + try: + self.get_anime(69, ignore_cache=True) + except Failed: + self.client = None + self.version = None + raise + + @property + def is_authorized(self): + return self.client is not None def login(self, username, password): self.username = username @@ -72,12 +105,12 @@ class AniDB: if not self._request(urls["login"], data=data).xpath("//li[@class='sub-menu my']/@title"): raise Failed("AniDB Error: Login failed") - def _request(self, url, data=None): + def _request(self, url, params=None, data=None): logger.trace(f"URL: {url}") if data: - return self.config.post_html(url, data=data, headers=util.header(self.language)) + return self.config.post_html(url, params=params, data=data, headers=util.header(self.language)) else: - return self.config.get_html(url, headers=util.header(self.language)) + return self.config.get_html(url, params=params, headers=util.header(self.language)) def _popular(self): response = self._request(urls["popular"]) @@ -119,8 +152,28 @@ class AniDB: current_url = f"{base_url}{next_page_list[0]}" return anidb_ids[:limit] - def get_anime(self, anidb_id): - return AniDBObj(self, anidb_id, self.language) + def get_anime(self, anidb_id, ignore_cache=False): + expired = None + anidb_dict = None + if self.config.Cache and not ignore_cache: + anidb_dict, expired = self.config.Cache.query_anidb(anidb_id, self.expiration) + if expired or not anidb_dict: + time_check = time.time() + if self._delay is not None: + while time_check - self._delay < 2: + time_check = time.time() + anidb_dict = self._request(api_url, params={ + "client": self.client, + "clientver": self.version, + "protover": 1, + "request": "anime", + "aid": anidb_id + }) + self._delay = time.time() + obj = AniDBObj(self, anidb_id, anidb_dict) + if self.config.Cache and not ignore_cache: + self.config.Cache.update_mdb(expired, anidb_id, obj, self.expiration) + return obj def get_anidb_ids(self, method, data): anidb_ids = [] diff --git a/modules/cache.py b/modules/cache.py index 5f880fa8..eed5bde5 100644 --- a/modules/cache.py +++ b/modules/cache.py @@ -118,6 +118,19 @@ class Cache: certification TEXT, expiration_date TEXT)""" ) + cursor.execute( + """CREATE TABLE IF NOT EXISTS anidb_data ( + key INTEGER PRIMARY KEY, + anidb_id INTEGER UNIQUE, + main_title TEXT, + titles TEXT, + rating REAL, + average REAL, + score REAL, + released TEXT, + tags TEXT, + expiration_date TEXT)""" + ) cursor.execute( """CREATE TABLE IF NOT EXISTS tmdb_movie_data ( key INTEGER PRIMARY KEY, @@ -471,6 +484,41 @@ class Cache: expiration_date.strftime("%Y-%m-%d"), key_id )) + def query_anidb(self, anidb_id, expiration): + anidb_dict = {} + expired = None + with sqlite3.connect(self.cache_path) as connection: + connection.row_factory = sqlite3.Row + with closing(connection.cursor()) as cursor: + cursor.execute("SELECT * FROM anidb_data WHERE anidb_id = ?", (anidb_id,)) + row = cursor.fetchone() + if row: + anidb_dict["main_title"] = row["main_title"] + anidb_dict["titles"] = row["titles"] if row["titles"] else None + anidb_dict["rating"] = row["rating"] if row["rating"] else None + anidb_dict["average"] = row["average"] if row["average"] else None + anidb_dict["score"] = row["score"] if row["score"] else None + anidb_dict["released"] = row["released"] if row["released"] else None + anidb_dict["tags"] = row["tags"] if row["tags"] else None + datetime_object = datetime.strptime(row["expiration_date"], "%Y-%m-%d") + time_between_insertion = datetime.now() - datetime_object + expired = time_between_insertion.days > expiration + return anidb_dict, expired + + def update_anidb(self, expired, anidb_id, anidb, expiration): + expiration_date = datetime.now() if expired is True else (datetime.now() - timedelta(days=random.randint(1, expiration))) + with sqlite3.connect(self.cache_path) as connection: + connection.row_factory = sqlite3.Row + with closing(connection.cursor()) as cursor: + cursor.execute("INSERT OR IGNORE INTO anidb_data(anidb_id) VALUES(?)", (anidb_id,)) + update_sql = "UPDATE anidb_data SET main_title = ?, titles = ?, rating = ?, average = ?, score = ?, " \ + "released = ?, tags = ?, expiration_date = ? WHERE anidb_id = ?" + cursor.execute(update_sql, ( + anidb.main_title, str(anidb.titles), anidb.rating, anidb.average, anidb.score, + anidb.released.strftime("%Y-%m-%d") if anidb.released else None, "|".join(anidb.tags), + expiration_date.strftime("%Y-%m-%d"), anidb_id + )) + def query_tmdb_movie(self, tmdb_id, expiration): tmdb_dict = {} expired = None diff --git a/modules/config.py b/modules/config.py index d01266f3..ada19014 100644 --- a/modules/config.py +++ b/modules/config.py @@ -472,11 +472,16 @@ class ConfigFile: else: logger.warning("mal attribute not found") - self.AniDB = AniDB(self, check_for_attribute(self.data, "language", parent="anidb", default="en")) + self.AniDB = AniDB(self, {"language": check_for_attribute(self.data, "language", parent="anidb", default="en")}) if "anidb" in self.data: logger.separator() logger.info("Connecting to AniDB...") try: + self.AniDB.authorize( + check_for_attribute(self.data, "client", parent="anidb", throw=True), + check_for_attribute(self.data, "version", parent="anidb", var_type="int", throw=True), + check_for_attribute(self.data, "cache_expiration", parent="anidb", var_type="int", default=60, int_min=1) + ) self.AniDB.login( check_for_attribute(self.data, "username", parent="anidb", throw=True), check_for_attribute(self.data, "password", parent="anidb", throw=True) @@ -750,6 +755,8 @@ class ConfigFile: error_check(mass_key, "OMDb") if params[mass_key] and params[mass_key].startswith("mdb") and not self.Mdblist.has_key: error_check(mass_key, "MdbList") + if params[mass_key] and params[mass_key].startswith("anidb") and not self.AniDB.is_authorized: + error_check(mass_key, "AniDB") if params[mass_key] and params[mass_key].startswith("trakt") and self.Trakt is None: error_check(mass_key, "Trakt")