-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_ed2k_links.py
executable file
·37 lines (30 loc) · 1.01 KB
/
get_ed2k_links.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3
import anime
import configparser
import argparse
import os.path
def get_config(
config_file: str = os.path.expanduser("~/.config/weltschmerz/weltschmerz.cfg"),
):
config = configparser.ConfigParser()
config.read_file(open(config_file))
parser = argparse.ArgumentParser(
description="Print ed2k links for specified folder(s)."
)
parser.add_argument(
"--database", help="database to use", default=config.get("client", "database")
)
parser.add_argument("--folders", nargs="*", help="folders to process", default="/")
args = parser.parse_args()
return args
if __name__ == "__main__":
config = get_config()
dbs = anime.DatabaseSession(config.database, False)
for folder in config.folders:
known_files = (
dbs.session.query(anime.LocalFile)
.filter(anime.LocalFile.directory.like(f'{folder.rstrip("/")}%'))
.all()
)
for known_file in known_files:
print(known_file.ed2k_link)