add alokal

This commit is contained in:
simon 2019-09-08 10:15:11 -04:00
parent 012a7813ef
commit 2a219b5c38
3 changed files with 33 additions and 5 deletions

View File

@ -5,7 +5,7 @@ image boards and publishes serialised JSON to RabbitMQ
for real-time ingest. for real-time ingest.
Compatible image boards: 4chan, lainchan, uboachan, Compatible image boards: 4chan, lainchan, uboachan,
22chan, wizchan, 1chan, 2ch.hk, endchan, 38chan. 22chan, wizchan, 1chan, 2ch.hk, endchan, 38chan, alokal.
Can optionally push monitoring data to InfluxDB. Below is an Can optionally push monitoring data to InfluxDB. Below is an
example of Grafana being used to display it. example of Grafana being used to display it.

28
chan.py
View File

@ -225,6 +225,22 @@ class RussianJsonChanHelper(ChanHelper):
return list(urls) return list(urls)
class AlokalJsonChanHelper(JsonChanHelper):
def item_urls(self, item, board):
urls = set()
if "com" in item and item["com"]:
urls.update(get_links_from_body(item["com"]))
elif "sub" in item and item["sub"]:
urls.update(get_links_from_body(item["sub"]))
if "fsize" in item and item["fsize"]:
urls.add(self._base_url + self._image_path + item["tim"] + "/" + str(item["no"]) + item["ext"])
return list(urls)
CHANS = { CHANS = {
"4chan": JsonChanHelper( "4chan": JsonChanHelper(
1, 1,
@ -355,5 +371,17 @@ CHANS = {
"a", "b", "g", "38" "a", "b", "g", "38"
), ),
rps=1 / 600 rps=1 / 600
),
"alokal": AlokalJsonChanHelper(
10,
"https://alokal.eu/",
"https://alokal.eu/",
"/",
"src/",
(
"b", "pol", "sk", "int", "slav", "s", "gv", "mda", "sp",
"fit", "had",
),
rps=1 / 4
) )
} }

View File

@ -40,7 +40,7 @@ def b64hash(imhash, bcount):
def image_meta(url, url_idx, web): def image_meta(url, url_idx, web):
r = web.get(url) r = web.get(url)
if not r: if not r:
logger.warning("") logger.warning("Could not download image")
return None return None
buf = r.content buf = r.content