mirror of
https://github.com/Death916/c2cscrape.git
synced 2026-04-10 03:04:40 -07:00
logged into qbit
This commit is contained in:
parent
f79c54f993
commit
5b542ae2cc
1 changed files with 17 additions and 8 deletions
|
|
@ -5,7 +5,9 @@ import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
from this import d
|
||||||
import time
|
import time
|
||||||
|
from turtle import done
|
||||||
|
|
||||||
import qbittorrentapi as qbapi
|
import qbittorrentapi as qbapi
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -48,6 +50,7 @@ class TorrentScrape:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_torrent_link(self):
|
def get_torrent_link(self):
|
||||||
|
links = []
|
||||||
page = self.get_torrent_page()
|
page = self.get_torrent_page()
|
||||||
if not page:
|
if not page:
|
||||||
logging.error("No page found")
|
logging.error("No page found")
|
||||||
|
|
@ -82,6 +85,7 @@ class TorrentScrape:
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
link = a.get("href")
|
link = a.get("href")
|
||||||
|
links.append(link)
|
||||||
self.episodes_downloaded += 1
|
self.episodes_downloaded += 1
|
||||||
logging.info(f"found episode {title}")
|
logging.info(f"found episode {title}")
|
||||||
logging.debug(f"link: {link}")
|
logging.debug(f"link: {link}")
|
||||||
|
|
@ -89,7 +93,7 @@ class TorrentScrape:
|
||||||
logging.info("done")
|
logging.info("done")
|
||||||
logging.info(f"Downloaded {self.episodes_downloaded} episodes")
|
logging.info(f"Downloaded {self.episodes_downloaded} episodes")
|
||||||
logging.info("Returning link to qbit")
|
logging.info("Returning link to qbit")
|
||||||
return link # need to return link later to qbit but need to decide logic
|
return links # need to return link later to qbit but need to decide logic
|
||||||
|
|
||||||
|
|
||||||
class Qbittorrent:
|
class Qbittorrent:
|
||||||
|
|
@ -109,30 +113,35 @@ class Qbittorrent:
|
||||||
if not self.username or not self.password:
|
if not self.username or not self.password:
|
||||||
raise ValueError("QB_USERNAME and QB_PASSWORD must be set in .env file")
|
raise ValueError("QB_USERNAME and QB_PASSWORD must be set in .env file")
|
||||||
|
|
||||||
def add_torrent(self, link):
|
def add_torrent(self, links):
|
||||||
conn_info = dict(
|
conn_info = dict(
|
||||||
host=self.host,
|
host=self.host,
|
||||||
port=self.port,
|
port=self.port,
|
||||||
username=self.username,
|
username=self.username,
|
||||||
password=self.password,
|
password=self.password,
|
||||||
)
|
)
|
||||||
|
logging.info(f"Logging in as {self.username} to host {self.host}:{self.port}")
|
||||||
torrent = qbapi.Client(**conn_info)
|
torrent = qbapi.Client(**conn_info)
|
||||||
try:
|
try:
|
||||||
torrent.auth_log_in()
|
torrent.auth_log_in()
|
||||||
logging.info("Logged in to qbittorrent")
|
logging.info("Logged in to qbittorrent")
|
||||||
|
logging.info(f"qbittorrent version: {torrent.app.version}")
|
||||||
|
|
||||||
except qbapi.LoginFailed:
|
except qbapi.LoginFailed:
|
||||||
logging.error("Failed to login to qbittorrent")
|
logging.error("Failed to login to qbittorrent")
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"Error adding torrent to qbittorrent: {e}")
|
for link in links:
|
||||||
raise
|
try:
|
||||||
|
torrent.torrents_add(urls=link,download_path=)
|
||||||
|
logging.info(f"Added torrent {link} to qbittorrent")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Error adding torrent {link} to qbittorrent: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
qbit = Qbittorrent()
|
pass
|
||||||
qbit.get_credentials()
|
|
||||||
qbit.add_torrent(link)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue