all repos — sunstroke @ 585855a8728f87cc5383329bd227f6d6ba840aff

main.py (view raw)

 1from Overpost import get_newspaper
 2from MyPyload import Pyload
 3from os import getenv
 4
 5NEWSPAPER_PREFIX = getenv("NEWSPAPER_PREFIX") or ""
 6
 7def scroll_dict(dictionary):
 8    i = 0
 9    for key, values in dictionary.items():
10        if i >= len(values):
11            i = 0
12        yield key, values[i]
13        i += 1
14
15def download_link(connection, name, link):
16    return connection.addPackage(name=name, links=[link])
17
18def main():
19    newspapers = get_newspaper(NEWSPAPER_PREFIX, 0) # 0 -> today
20    con = Pyload()
21    pids = [ download_link(con, NEWSPAPER_PREFIX, link) for _, link in scroll_dict(newspapers) ]
22    print(pids)
23
24if __name__ == "__main__":
25    exit(main())