Skip to content

Commit

Permalink
Merge pull request #34 from yachtrock87/update-scraping
Browse files Browse the repository at this point in the history
Update scraping
  • Loading branch information
kannibalox authored Oct 4, 2024
2 parents 0f59651 + 2a685dd commit d830fcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/ptpapi/movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, ID=None, data=None):
"Tags",
"Directors",
"PtpRating",
"PtpVoteCount",
"PtpRatingCount",
"UserRating",
"Seen",
"Snatched",
Expand Down Expand Up @@ -111,10 +111,10 @@ def load_html_data(self):
"html.parser",
)
self.data["Cover"] = soup.find("img", class_="sidebar-cover-image")["src"]
# Title and Year
# Title
match = re.match(
rb"(.*)(:? \[(\d{4})\])?",
soup.find("h2", class_="page__title").encode_contents(),
r"(.*:?) \[(\d{4})\]",
soup.find("h2", class_="page__title").get_text(),
)
self.data["Title"] = match.group(1)
# Type
Expand Down Expand Up @@ -154,6 +154,10 @@ def load_html_data(self):
self.data["Snatched"] = True

# File list & trumpability for torrents
# Populate torrent IDs if not already populated
if "Torrents" not in self.data.keys():
self.data["Torrents"] = [torrent.Torrent(
re.match(r"torrent_(\d*)", torr['id']).group(1)) for torr in soup.find_all("tr", class_="torrent_info_row")]
for tor in self.data["Torrents"]:
# Get file list
filediv = soup.find("div", id="files_%s" % tor.ID)
Expand Down
5 changes: 4 additions & 1 deletion src/ptpapi/scripts/ptp.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ def parse_terms(termlist):
terms = url_args
elif url.path == "/torrents.php":
if "torrentid" in url_args:
torrents.append(ptpapi.Torrent(url_args["torrentid"][0]))
if "id" in url_args:
torrents.append(ptpapi.Torrent(data={"Id":url_args["torrentid"][0], "GroupId":url_args["id"][0]}))
else:
torrents.append(ptpapi.Torrent(url_args["torrentid"][0]))
elif "id" in url_args:
if "action" in url_args and url_args["action"][0] == "download":
torrents.append(ptpapi.Torrent(url_args["id"][0]))
Expand Down

0 comments on commit d830fcc

Please sign in to comment.