Skip to content

Commit b8cac09

Browse files
committed
fix(extractor.py): 修复实况作品下载功能
1. 修复作品文件后缀名错误的问题 2. 支持混合实况作品下载
1 parent 3fc4c67 commit b8cac09

File tree

3 files changed

+51
-42
lines changed

3 files changed

+51
-42
lines changed

README_EN.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@
1313
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/TikTokDownloader/total?style=for-the-badge&color=52c41a">
1414
</div>
1515
<br>
16-
<p>🔥 <b>TikTok Account Works/Collections/Live Streams/Videos/Albums/Music; Douyin Account Works/Videos/Albums/Favorites/Live Streams/Music/Collections/Comments/Account Data/Search Data/Popular List Data Acquisition Tools:</b> Fully open-source, free tools implemented based on the HTTPX module; batch download of Douyin account published works, liked works, and favorited works; batch download of TikTok account published works and liked works; download of Douyin linked or TikTok linked works; obtain Douyin live stream push addresses; download Douyin live stream videos; obtain TikTok live stream push addresses; download TikTok live stream videos; collect Douyin works comment data; batch download of Douyin Collections works; batch download of TikTok Collections works; collect detailed data of Douyin accounts; collect Douyin user/work/live stream search results; collect Douyin popular list data.</p>
16+
<p>🔥 <b>TikTok Account Works/Mix/Live/Video/Image/Music; Douyin Account Works/Video/Image/LivePhoto/Favorites/Live/Music/Collections/Comments/Account Data/Search Data/Hot Board Data Acquisition Tools:</b> Fully open-source, free tools implemented based on the HTTPX module; batch download of Douyin account posts works, liked works, and collections works; batch download of TikTok account posts works and liked works; download of Douyin linked or TikTok linked works; obtain Douyin live stream addresses; download Douyin live stream video; obtain TikTok live stream addresses; download TikTok live stream video; collect Douyin works comment data; batch download of Douyin Mix works; batch download of TikTok Mix works; collect detailed data of Douyin accounts; collect Douyin user/works/live search results; collect Douyin Hot Board data.</p>
1717
<p>⭐ This project is completely free and open-source, with no paid features. Please do not be deceived!</p>
1818
<p>⭐ Due to the author's limited energy, I was unable to update the English document in a timely manner, and the content may have become outdated, partial translation is machine translation, the translation result may be incorrect, Suggest referring to Chinese documentation. If you want to contribute to translation, we warmly welcome you.</p>
1919
<hr>
2020

2121
# 📝 Project Features
2222

23-
* ✅ Download Douyin videos/albums without watermarks
24-
* ✅ Download TikTok videos/albums without watermarks
25-
* ✅ Batch download of Douyin account published/liked/favorited works
26-
* ✅ Batch download of TikTok account published/liked works
23+
* ✅ Download Douyin video/image without watermarks
24+
* ✅ Download TikTok video/image without watermarks
25+
* ✅ Batch download of Douyin account posts/liked/favorites works
26+
* ✅ Batch download of TikTok account posts/liked works
2727
* ✅ Collect detailed data from Douyin/TikTok
2828
* ✅ Batch download of linked works
2929
* ✅ Batch download of works from multiple accounts
3030
* ✅ Automatically skip already downloaded files
3131
* ✅ Persistently save collected data
3232
* ✅ Download dynamic/static cover images
33-
* ✅ Obtain Douyin live stream push addresses
34-
* ✅ Obtain TikTok live stream push addresses
35-
* ✅ Use ffmpeg to download live streams
33+
* ✅ Obtain Douyin live stream addresses
34+
* ✅ Obtain TikTok live stream addresses
35+
* ✅ Use ffmpeg to download live video
3636
* ✅ Web UI interaction interface
3737
* ✅ Collect comment data from Douyin works
38-
* ✅ Batch download of Douyin Collections works
39-
* ✅ Batch download of TikTok Collections works
38+
* ✅ Batch download of Douyin Mix works
39+
* ✅ Batch download of TikTok Mix works
4040
* ✅ Record statistics such as likes and favorites
4141
* ✅ Filter works based on publication time
4242
* ✅ Support incremental downloading of account works
@@ -48,7 +48,7 @@
4848
* ✅ Deploy to private servers
4949
* ✅ Deploy to public servers
5050
* ✅ Collect Douyin search data
51-
* ✅ Collect Douyin hot list data
51+
* ✅ Collect Douyin hot board data
5252
* ✅ Record IDs of already downloaded works
5353
* ☑️ ~~Scan QR code to log in and obtain Cookies~~
5454
* ✅ Obtain Cookies from browsers
@@ -165,23 +165,23 @@
165165

166166
[Click to view Cookie tutorial](https://github.com/JoeanAmier/TikTokDownloader/blob/master/docs/Cookie%E8%8E%B7%E5%8F%96%E6%95%99%E7%A8%8B.md)
167167

168-
| Program Function | Login Required |
169-
|:---------------------------------:|:----------------------:|
170-
| Download Account Published Works | ⭕ Recommended to Login |
171-
| Download Account Liked Works | ⭕ Recommended to Login |
172-
| Download Linked Works | ⭕ Recommended to Login |
173-
| Obtain Live Stream Push Address | ❌ No Login Required |
174-
| Download Live Stream Videos | ❌ No Login Required |
175-
| Obtain Work Comment Data | ⭕ Recommended to Login |
176-
| Download Collections Works | ⭕ Recommended to Login |
177-
| Obtain Account Data | ⭕ Recommended to Login |
178-
| Collect Search Results | ⭕ Recommended to Login |
179-
| Collect Hot List Data | ❌ No Login Required |
180-
| Download Favorited Works | ✔️ Login Required |
181-
| Download Favorites Folder Works | ✔️ Login Required |
182-
| Obtain Favorites Collections Data | ✔️ Login Required |
183-
| Obtain Favorites Music Data | ✔️ Login Required |
184-
| Obtain Favorites Short Drama Data | ✔️ Login Required |
168+
| Program Function | Login Required |
169+
|:----------------------------:|:----------------------:|
170+
| Download Account Posts Works | ⭕ Recommended to Login |
171+
| Download Account Liked Works | ⭕ Recommended to Login |
172+
| Download Linked Works | ⭕ Recommended to Login |
173+
| Obtain Live Stream Address | ❌ No Login Required |
174+
| Download Live Video | ❌ No Login Required |
175+
| Obtain Works Comment Data | ⭕ Recommended to Login |
176+
| Download Mix Works | ⭕ Recommended to Login |
177+
| Obtain Account Data | ⭕ Recommended to Login |
178+
| Collect Search Results | ⭕ Recommended to Login |
179+
| Collect Hot Board Data | ❌ No Login Required |
180+
| Download Favorites Works | ✔️ Login Required |
181+
| Download Collections Works | ✔️ Login Required |
182+
| Obtain Collections Mix | ✔️ Login Required |
183+
| Obtain Collections Music | ✔️ Login Required |
184+
| Obtain Collections Series | ✔️ Login Required |
185185

186186
> * Cookie only needs to be re-written to the configuration file after it expires, and not every time the program is
187187
run.
@@ -197,11 +197,11 @@
197197

198198
<ul>
199199
<li>When the program prompts the user for input, pressing Enter directly will return to the previous menu, and inputting <code>Q</code> or <code>q</code> will end the program's execution.</li>
200-
<li>Since fetching data for liked and favorited works of an account only returns the publication dates of those works, not the dates of the actions (liking or favoriting), the program needs to retrieve all liked and favorited works data before performing date filtering. If there are a large number of works, this may take a considerable amount of time. The number of requests can be controlled via the <code>max_pages</code> parameter.</li>
200+
<li>Since fetching data for liked and favorites works of an account only returns the publication dates of those works, not the dates of the actions (liking or favouring), the program needs to retrieve all liked and favorites works data before performing date filtering. If there are a large number of works, this may take a considerable amount of time. The number of requests can be controlled via the <code>max_pages</code> parameter.</li>
201201
<li>To obtain data for posts made by a private account, a logged-in Cookie is required, and the logged-in account must follow the private account.</li>
202-
<li>When batch downloading works or Collections works of an account, if the corresponding nickname or identifier changes, the program will automatically update the nickname and identifier in the file names of the downloaded works.</li>
202+
<li>When batch downloading account posts works or mix works, if the corresponding nickname or mark parameter changes, the program will automatically update the nickname and mark parameter in the file names of the downloaded works.</li>
203203
<li>When downloading files, the program first downloads them to a temporary folder and then moves them to the storage folder upon completion. The temporary folder will be emptied when the program ends.</li>
204-
<li>The <code>Batch Download Favorited Works Mode</code> currently only supports downloading favorited works for the account corresponding to the currently logged-in Cookie and does not support multiple accounts.</li>
204+
<li>The <code>Batch Download Favorites Works Mode</code> currently only supports downloading favorited works for the account corresponding to the currently logged-in Cookie and does not support multiple accounts.</li>
205205
<li>If you want the program to use a proxy to request data, you must set the <code>proxy</code> parameter in <code>settings.json</code>; otherwise, the program will not use a proxy.</li>
206206
<li>To exit the program, please end it in a normal way or by pressing Ctrl + C. Do not directly close the terminal window, as this may result in data loss.</li>
207207
<li>If your computer does not have a suitable program for editing JSON files, we recommend using the <a href="https://try8.cn/tool/format/json">JSON Online Tool</a> to edit the configuration file content.</li>

src/downloader/download.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Downloader:
4747
semaphore = Semaphore(MAX_WORKERS)
4848
CONTENT_TYPE_MAP = {
4949
"image/png": "png",
50-
"image/jpeg": "jpg",
50+
"image/jpeg": "jpeg",
5151
"image/webp": "webp",
5252
"video/mp4": "mp4",
5353
"video/quicktime": "mov",
@@ -290,12 +290,15 @@ async def downloader_chart(
290290
semaphore: Semaphore = None,
291291
**kwargs):
292292
with progress:
293-
tasks = [self.request_file(
294-
*task,
295-
count=count,
296-
**kwargs,
297-
progress=progress,
298-
semaphore=semaphore, ) for task in tasks]
293+
tasks = [
294+
self.request_file(
295+
*task,
296+
count=count,
297+
**kwargs,
298+
progress=progress,
299+
semaphore=semaphore,
300+
) for task in tasks
301+
]
299302
await gather(*tasks)
300303

301304
def deal_folder_path(self,
@@ -502,7 +505,7 @@ async def request_file(
502505
case 1:
503506
return await self.download_file(
504507
temp,
505-
actual,
508+
actual.with_suffix(f".{suffix}", ),
506509
show,
507510
id_,
508511
response,
@@ -644,7 +647,8 @@ def generate_detail_name(self, data: dict) -> str:
644647
return beautify_string(
645648
self.cleaner.filter_name(
646649
self.split.join(
647-
data[i] for i in self.name_format),
650+
data[i] for i in self.name_format
651+
),
648652
data["id"],
649653
), length=MAX_FILENAME_LENGTH,
650654
)

src/extract/extractor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def __extract_image_info(
360360
if self.safe_extract(images[-1], "video"):
361361
self.__set_blank_data(item, data, _("实况"), )
362362
item["downloads"] = [
363-
self.__extract_video_download(i, ) for i in images
363+
self.__classify_slides_item(i, ) for i in images
364364
]
365365
else:
366366
self.__set_blank_data(item, data, _("图集"), )
@@ -409,6 +409,11 @@ def __extract_video_info(
409409
data, "video.play_addr.uri")
410410
self.__extract_cover(item, data, True)
411411

412+
def __classify_slides_item(self, item: SimpleNamespace, ) -> str:
413+
if self.safe_extract(item, "video"):
414+
return self.__extract_video_download(item, )
415+
return self.safe_extract(item, f'url_list[{IMAGE_INDEX}]')
416+
412417
def __extract_video_download(self, data: SimpleNamespace, ) -> str:
413418
bit_rate: list[SimpleNamespace] = self.safe_extract(
414419
data,
@@ -425,7 +430,7 @@ def __extract_video_download(self, data: SimpleNamespace, ) -> str:
425430
return self.safe_extract(
426431
bit_rate[-1][-1],
427432
f"url_list[{VIDEO_INDEX}]",
428-
)
433+
) if bit_rate else ""
429434

430435
def __extract_video_info_tiktok(
431436
self,

0 commit comments

Comments
 (0)