def copy_torrent_file(): with serverDatabase.ServerDatabase() as db: newest_release = db.get_newest_release() shutil.copy2( os.path.join( os.path.split(newest_release["path"])[0], newest_release["torrent"]), "static")
def main(): with Browser() as browser: with serverDatabase.ServerDatabase() as db: for product_url in get_product_urls(): if get_id_from_url(product_url) in get_completed(): print("Skipping id... Already processed") continue pagedata = browser.rip_page(product_url) if pagedata is None: continue try: db.add_product(pagedata) except Exception as e: print("ERROR", e)
def seed(release=False): with serverDatabase.ServerDatabase() as db: if release: db.export_db() torrentinfo = db.get_newest_release() stc = ServerTorrentClient() tc = torrentClient.TorrentClient(stc.get_queue(), os.path.join( os.path.split(torrentinfo["path"])[0], torrentinfo["torrent"]), os.path.split(torrentinfo["path"])[0], seeding_mode=True) tc.start() try: stc.main(verbose=True) except KeyboardInterrupt: tc.stop_event.set() del stc print("\nExiting nicely...\n")
def get_product(): prod_id = flask.request.args.get("id", type=int) with serverDatabase.ServerDatabase() as db: return flask.jsonify(db.get_product(prod_id))
def get_torrent(): with serverDatabase.ServerDatabase() as db: filename = db.get_newest_release()["torrent"] return app.send_static_file(filename)