Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: parsing timestamp from filename (Transflix) (#1438)

Barbarella666666626d8b2e8fae1
diff --git a/cyberdrop_dl/crawlers/transflix.py b/cyberdrop_dl/crawlers/transflix.py
index 832c70cf3..22a37f955 100644
--- a/cyberdrop_dl/crawlers/transflix.py
+++ b/cyberdrop_dl/crawlers/transflix.py
@@ -51,7 +51,7 @@ class TransflixCrawler(Crawler):
video = css.select_one(soup, _SELECTORS.VIDEO)
link = self.parse_url(css.get_attr(video, "src"))
filename, ext = self.get_filename_and_ext(link.name)
- scrape_item.possible_datetime = int(Path(filename).stem)
+ scrape_item.possible_datetime = _timestamp_from_filename(link.name)
custom_filename = self.create_custom_filename(title, ext, file_id=video_id)
return await self.handle_file(link, scrape_item, filename, ext, custom_filename=custom_filename)
@@ -64,3 +64,12 @@ class TransflixCrawler(Crawler):
async for soup in self.web_pager(scrape_item.url, _SELECTORS.NEXT_PAGE):
for _, new_scrape_item in self.iter_children(scrape_item, soup, _SELECTORS.SEARCH_VIDEOS):
self.create_task(self.run(new_scrape_item))
+
+
+def _timestamp_from_filename(filename: str) -> int | None:
+ UNIX_TIMESTAMP_LENGTH: int = 10
+ stem = Path(filename).stem
+ if len(stem) >= UNIX_TIMESTAMP_LENGTH:
+ possible_timestamp = stem[-UNIX_TIMESTAMP_LENGTH:]
+ if possible_timestamp.isdecimal():
+ return int(possible_timestamp)
diff --git a/tests/crawlers/test_cases/transflix.py b/tests/crawlers/test_cases/transflix.py
index 6be79681b..e7bf6e486 100644
--- a/tests/crawlers/test_cases/transflix.py
+++ b/tests/crawlers/test_cases/transflix.py
@@ -16,4 +16,16 @@ TEST_CASES = [
[],
4,
),
+ # Timestamp mixed with leading letters
+ (
+ "https://transflix.net/video/hunnypaint-take-care-tranny-videos-xxx-43343",
+ [
+ {
+ "url": "https://cdn.transflix.net/video/2025-03-28/qa2cxgri1743182001.mp4",
+ "filename": "Hunnypaint - Take Care - Tranny Videos Xxx [43343].mp4",
+ "referer": "https://transflix.net/video/hunnypaint-take-care-tranny-videos-xxx-43343",
+ "datetime": 1743182001,
+ }
+ ],
+ ),
]