contentmatcher/populate_db_once.py

26 lines
810 B
Python
Raw Permalink Normal View History

from create_db import Card, get_session, get_engine
2022-05-19 23:56:32 +02:00
from config import CONFIG
import nextcloud_client
2022-05-19 23:56:32 +02:00
2022-06-14 14:47:12 +02:00
dbsession = get_session()
nc = nextcloud_client.Client('https://obzorje.kompot.si')
2022-06-13 14:30:28 +02:00
nc.login(CONFIG['NC_USER'],CONFIG['NC_PASSWORD'])
l = nc.list("/GIA CLOUD")
for item in l:
if item.get_name()[-4:] == ".pdf":
name = item.get_name()
public_share = nc.share_file_with_link("/GIA CLOUD/"+name)
public_link = public_share.get_link()+"/download/"+name
2022-06-13 14:30:28 +02:00
card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=public_link, last_review=None, share_id="0")
Session = get_session()
with Session() as dbsession:
dbsession.add(card)
dbsession.commit()
dbsession.close()
get_engine().dispose()