Dolda2000 GitWeb
/
utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8b09dc8
)
ann.py: Further improvements.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 25 Dec 2019 21:49:43 +0000
(22:49 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 25 Dec 2019 21:49:43 +0000
(22:49 +0100)
ann.py
patch
|
blob
|
blame
|
history
diff --git
a/ann.py
b/ann.py
index
0b583ff
..
4d2c5d1
100644
(file)
--- a/
ann.py
+++ b/
ann.py
@@
-3,6
+3,9
@@
from urllib.parse import urljoin, urlencode
import bs4
soup = lambda cont: bs4.BeautifulSoup(cont, "html.parser")
import bs4
soup = lambda cont: bs4.BeautifulSoup(cont, "html.parser")
+__all__ = ["anime", "getlist",
+ "error", "incompatible"]
+
base = "http://www.animenewsnetwork.com/encyclopedia/"
class error(Exception):
base = "http://www.animenewsnetwork.com/encyclopedia/"
class error(Exception):
@@
-63,6
+66,8
@@
def cstr(soup):
for el in soup:
ret += cstr(el)
return ret
for el in soup:
ret += cstr(el)
return ret
+ elif isinstance(soup, str):
+ return soup
elif soup is None:
return None
else:
elif soup is None:
return None
else:
@@
-145,6
+150,18
@@
class anime(object):
return ret
return int(ret)
return ret
return int(ret)
+ @cproperty
+ def vintage(self):
+ return cstr(self._info("vintage")).strip()
+
+ @cproperty
+ def genres(self):
+ return [cstr(el) for x in (self._info("genres") or []) if isinstance(x, bs4.Tag) for el in x.findAll("a")]
+
+ @cproperty
+ def themes(self):
+ return [cstr(el) for x in (self._info("themes") or []) if isinstance(x, bs4.Tag) for el in x.findAll("a")]
+
def __repr__(self):
return "<ann.anime: %r (%i)>" % (self.name, self.id)
def __repr__(self):
return "<ann.anime: %r (%i)>" % (self.name, self.id)