mirror of
https://github.com/Death916/c2cscrape.git
synced 2026-04-10 03:04:40 -07:00
cleanup and works. adds torrents to client
This commit is contained in:
parent
60a7d441f6
commit
83e53bba5c
1 changed files with 4 additions and 13 deletions
|
|
@ -1,11 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import datetime
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
import re
|
|
||||||
import time
|
|
||||||
|
|
||||||
import qbittorrentapi as qbapi
|
import qbittorrentapi as qbapi
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -32,10 +28,6 @@ class TorrentScrape:
|
||||||
self.episodes_downloaded = 0
|
self.episodes_downloaded = 0
|
||||||
self.download_location = "/downloads"
|
self.download_location = "/downloads"
|
||||||
|
|
||||||
def sanitize_filename(self, filename):
|
|
||||||
# Remove or replace invalid filename characters
|
|
||||||
return re.sub(r'[<>:"/\\|?*]', "-", filename)
|
|
||||||
|
|
||||||
def get_torrent_page(self):
|
def get_torrent_page(self):
|
||||||
try:
|
try:
|
||||||
response = requests.get(self.url, headers=self.headers)
|
response = requests.get(self.url, headers=self.headers)
|
||||||
|
|
@ -63,9 +55,7 @@ class TorrentScrape:
|
||||||
|
|
||||||
episode_elems = main_class.select(".text-wrap.w-100")
|
episode_elems = main_class.select(".text-wrap.w-100")
|
||||||
if episode_elems:
|
if episode_elems:
|
||||||
print(
|
print(f"Found {len(episode_elems)} episodes")
|
||||||
f"Found {len(episode_elems)} episode elements using selector .text-wrap.w-100"
|
|
||||||
)
|
|
||||||
if len(episode_elems) > self.download_amount:
|
if len(episode_elems) > self.download_amount:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Too many episodes found, only downloading last {self.download_amount}"
|
f"Too many episodes found, only downloading last {self.download_amount}"
|
||||||
|
|
@ -125,6 +115,8 @@ class Qbittorrent:
|
||||||
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}")
|
logging.info(f"qbittorrent version: {torrent.app.version}")
|
||||||
|
torrent.auth_log_out()
|
||||||
|
logging.info("Logged out of qbittorrent")
|
||||||
|
|
||||||
except qbapi.LoginFailed:
|
except qbapi.LoginFailed:
|
||||||
logging.error("Failed to login to qbittorrent")
|
logging.error("Failed to login to qbittorrent")
|
||||||
|
|
@ -150,7 +142,6 @@ if __name__ == "__main__":
|
||||||
torrent = Qbittorrent()
|
torrent = Qbittorrent()
|
||||||
torrent.get_credentials()
|
torrent.get_credentials()
|
||||||
torrent.add_torrent(link)
|
torrent.add_torrent(link)
|
||||||
# Keep main thread alive with minimal resource usage
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue