Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
add mime_type checking for pixeldrain in event of noextensionfailure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-WinnfieldX committed Apr 8, 2024
1 parent fd975ce commit 5c9f278
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.2.19"
__version__ = "5.2.21"
17 changes: 15 additions & 2 deletions cyberdrop_dl/scraper/crawlers/pixeldrain_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from aiolimiter import AsyncLimiter
from yarl import URL

from cyberdrop_dl.clients.errors import NoExtensionFailure
from cyberdrop_dl.scraper.crawler import Crawler
from cyberdrop_dl.utils.dataclasses.url_objects import ScrapeItem
from cyberdrop_dl.utils.utilities import error_handling_wrapper, get_filename_and_ext
Expand Down Expand Up @@ -48,7 +49,13 @@ async def folder(self, scrape_item: ScrapeItem) -> None:
for file in JSON_Resp['files']:
link = await self.create_download_link(file['id'])
date = await self.parse_datetime(file['date_upload'].replace("T", " ").split(".")[0].strip("Z"))
filename, ext = await get_filename_and_ext(file['name'])
try:
filename, ext = await get_filename_and_ext(JSON_Resp['name'])
except NoExtensionFailure:
if "image" or "video" in file["mime_type"]:
filename, ext = await get_filename_and_ext(JSON_Resp['name'] + "." + file["mime_type"].split("/")[-1])
else:
raise NoExtensionFailure
new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True, None, date)
if not await self.check_album_results(link, results):
await self.handle_file(link, new_scrape_item, filename, ext)
Expand All @@ -61,7 +68,13 @@ async def file(self, scrape_item: ScrapeItem) -> None:

link = await self.create_download_link(JSON_Resp['id'])
date = await self.parse_datetime(JSON_Resp['date_upload'].replace("T", " ").split(".")[0])
filename, ext = await get_filename_and_ext(JSON_Resp['name'])
try:
filename, ext = await get_filename_and_ext(JSON_Resp['name'])
except NoExtensionFailure:
if "image" or "video" in JSON_Resp["mime_type"]:
filename, ext = await get_filename_and_ext(JSON_Resp['name'] + "." + JSON_Resp["mime_type"].split("/")[-1])
else:
raise NoExtensionFailure
new_scrape_item = await self.create_scrape_item(scrape_item, link, "", False, None, date)
await self.handle_file(link, new_scrape_item, filename, ext)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
version = "5.2.19"
version = "5.2.21"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 5c9f278

Please sign in to comment.