Skip to content

Commit

Permalink
Fix loading torrent files
Browse files Browse the repository at this point in the history
  • Loading branch information
kannibalox committed Oct 13, 2023
1 parent d1ba384 commit 5d2861f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/PtpUploader/Job/LoadFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@


def load_json_release(path: Path):
data: Dict = json.load(path.open())
with path.open() as fh:
data: Dict = json.load(fh)
release = ReleaseInfo()
allowed_fields: List[str] = [
"ImdbId",
Expand All @@ -36,6 +37,13 @@ def load_json_release(path: Path):
release.save()
path.unlink()

def load_torrent_release(path: Path):
release = ReleaseInfo()
release.AnnouncementSourceName = "torrent"
release.SourceTorrentFilePath = path
release.JobRunningState = ReleaseInfo.JobState.WaitingForStart
release.save()
path.unlink()

def scan_dir():
path = Path(Settings.GetAnnouncementWatchPath())
Expand All @@ -45,7 +53,7 @@ def scan_dir():
load_json_release(child)
continue
except json.decoder.JSONDecodeError:
pass
logger.debug("Cannot load %r as JSON, attempting .torrent check", child)
try:
load_torrent_release(child)
continue
Expand Down

0 comments on commit 5d2861f

Please sign in to comment.