contentmatcher/populate_db_once.py

22 lines
677 B
Python
Raw Normal View History

2022-06-14 14:47:12 +02:00
from create_db import Card, get_session
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")
2022-05-19 23:56:32 +02:00
dbsession.add(card)
dbsession.commit()
2022-07-07 17:20:15 +02:00
dbsession.close()