Closed ChunlyShen closed 2 years ago
its been already reported in #126
Please solve the problem. It happened for many days(two weeks or longer?). Thank you, @jaysonlong
I open the "dispatcher.py" file and try to print the "subtitles" variable that I find the download link is incorrect, please see below
For example, Subtitles URL is: 'https://subtitle.wetvinfo.com/svp_50125/cdv-ATVenqQXzlY2xukZ_Qc8Ns_J-DCZy28GXQT5gNJf0x5wLpg93mSNkBH0BueEOrxfDvhEX_UfS9lk2pMZATDKEF4Rn4niLUhNJnEse758eLTJtTc_ztfmx6AIsd2irswrLTEwc2IEw70dXrwdmA/gzc_1000117_0b53jaaccaaaqeal4o5vbzqm2sgdefcaajca.f490105.vtt.m3u8?ver=4' (incorrect)
We can see the URL last name is:".vtt.m3u8?ver=4" However, the correct URL last name should be: ".vtt"
Therefore, the correct URL is: 'https://subtitle.wetvinfo.com/svp_50125/cdv-ATVenqQXzlY2xukZ_Qc8Ns_J-DCZy28GXQT5gNJf0x5wLpg93mSNkBH0BueEOrxfDvhEX_UfS9lk2pMZATDKEF4Rn4niLUhNJnEse758eLTJtTc_ztfmx6AIsd2irswrLTEwc2IEw70dXrwdmA/gzc_1000117_0b53jaaccaaaqeal4o5vbzqm2sgdefcaajca.f490105.vtt' (correct)
I only know the error, but I don't know how to fix it.
By the way, if someone wants to download subtitles they can print "subtitles variable" to get the correct link before the error is fixed.
I open the "dispatcher.py" file and try to print the "subtitles" variable that I find the download link is incorrect, please see below
For example, Subtitles URL is: 'https://subtitle.wetvinfo.com/svp_50125/cdv-ATVenqQXzlY2xukZ_Qc8Ns_J-DCZy28GXQT5gNJf0x5wLpg93mSNkBH0BueEOrxfDvhEX_UfS9lk2pMZATDKEF4Rn4niLUhNJnEse758eLTJtTc_ztfmx6AIsd2irswrLTEwc2IEw70dXrwdmA/gzc_1000117_0b53jaaccaaaqeal4o5vbzqm2sgdefcaajca.f490105.vtt.m3u8?ver=4' (incorrect)
We can see the URL last name is:".vtt.m3u8?ver=4" However, the correct URL last name should be: ".vtt"
Therefore, the correct URL is: 'https://subtitle.wetvinfo.com/svp_50125/cdv-ATVenqQXzlY2xukZ_Qc8Ns_J-DCZy28GXQT5gNJf0x5wLpg93mSNkBH0BueEOrxfDvhEX_UfS9lk2pMZATDKEF4Rn4niLUhNJnEse758eLTJtTc_ztfmx6AIsd2irswrLTEwc2IEw70dXrwdmA/gzc_1000117_0b53jaaccaaaqeal4o5vbzqm2sgdefcaajca.f490105.vtt' (correct)
I only know the error, but I don't know how to fix it.
By the way, if someone wants to download subtitles they can print "subtitles variable" to get the correct link before the error is fixed.
Thank you this was of great help in getting the subtitles even if I have a separate file.
When I opened .vtt file, I knew just added 8 lines on top of the file. Remove just 8 lines and rename .srt, it worked fine.
I open the "dispatcher.py" file and try to print the "subtitles" variable that I find the download link is incorrect, please see below
For example, Subtitles URL is: 'https://subtitle.wetvinfo.com/svp_50125/cdv-ATVenqQXzlY2xukZ_Qc8Ns_J-DCZy28GXQT5gNJf0x5wLpg93mSNkBH0BueEOrxfDvhEX_UfS9lk2pMZATDKEF4Rn4niLUhNJnEse758eLTJtTc_ztfmx6AIsd2irswrLTEwc2IEw70dXrwdmA/gzc_1000117_0b53jaaccaaaqeal4o5vbzqm2sgdefcaajca.f490105.vtt.m3u8?ver=4' (incorrect)
We can see the URL last name is:".vtt.m3u8?ver=4" However, the correct URL last name should be: ".vtt"
Therefore, the correct URL is: 'https://subtitle.wetvinfo.com/svp_50125/cdv-ATVenqQXzlY2xukZ_Qc8Ns_J-DCZy28GXQT5gNJf0x5wLpg93mSNkBH0BueEOrxfDvhEX_UfS9lk2pMZATDKEF4Rn4niLUhNJnEse758eLTJtTc_ztfmx6AIsd2irswrLTEwc2IEw70dXrwdmA/gzc_1000117_0b53jaaccaaaqeal4o5vbzqm2sgdefcaajca.f490105.vtt' (correct)
I only know the error, but I don't know how to fix it.
By the way, if someone wants to download subtitles they can print "subtitles variable" to get the correct link before the error is fixed.
Link has no problem but ffmpeg downloader not downloading vtt .
I fixed this issue. but my source is dirty. I learned python just 10 days. This is part of dispatcher.py. I confirmed only WeTV and IQIYI.
`
# For Only WeTV Global (Subtitle changed from webvtt to srt, just remove webvtt header)
# Just Remove webvtt header until "1"
def vtt_to_srt(self, vttFile):
myFile = open(vttFile, 'r')
vttfile = myFile.readlines()
myFile.close()
for i in range(0,15):
if ( vttfile[i].startswith('1') ):
break
vttfile[i]=''
srtFileName = vttFile.replace(".vtt",".srt")
srtFile = open(srtFileName, 'a')
srtFile.writelines(vttfile)
srtFile.close()
def handleSubtitles(self, subtitles, fileName, videoName, headers = {}):
print("-- dispatcher/handleSubtitles")
subtitleUrls, subtitleNames = [], []
subtitlesInfo = []
# For WeTV subtitle file process ( .vtt to .srt )
subtitleNames1, subtitlesInfo1 = [], []
for name, url in subtitles:
# remove .m3u8 from subtitle url
url = url.replace(".m3u8","")
subtitleUrls.append(url)
subtitleName = tools.join(self.tempFilePath, '%s_%s%s' % \
(fileName, name, tools.getSuffix(url)))
subtitleNames1.append(subtitleName)
subtitlesInfo1.append((name, subtitleName))
self.downloader.downloadAll(subtitleUrls, subtitleNames1, headers, self.hlsThreadCnt)
for each in subtitleNames1:
# IF subtitle name is .vtt (This is WeTV)
if ( ".vtt" in each ):
# Convert vtt to srt
self.vtt_to_srt(each)
# subtitle name extension change from vtt to srt
each = each.replace(".vtt",".srt")
subtitleNames.append(each)
tools.tryFixSrtFile(each)
# for delete vtt file
each = each.replace(".srt",".vtt")
os.remove(each)
else:
subtitleNames.append(each)
tools.tryFixSrtFile(each)
for name1, each1 in subtitlesInfo1:
# IF subtitle name is .vtt (This is WeTV)
if ( ".vtt" in each1 ):
# subtitle name extension change from vtt to srt
each1 = each1.replace(".vtt",".srt")
subtitlesInfo.append((name1, each1))
targetFileName = tools.integrateSubtitles(subtitlesInfo, videoName)
self.saveTempFile or tools.removeFiles(subtitleNames)
return targetFileName
`
Hi @enaskr. Sorry, I'm new that I change my code to your code and I get the error msg.
The below photo is my code. What's wrong with my code?
Hi @enaskr. Sorry, I'm new that I change my code to your code and I get the error msg.
The below photo is my code. What's wrong with my code?
line 97 myFile = open(vttFile, 'r', encoding='utf-8') line 107 srtFile = open(srtFileName, 'a', encoding='utf-8')
Hi @ssettor, Thanks a lot for your reply! I edited the code and it can work now! Thank you so much!!! : )
In summary, just follow @enaskr 's code (https://github.com/jaysonlong/webvideo-downloader/issues/128#issuecomment-1093729341 ). However, if it get some unicode error, please edit below (https://github.com/jaysonlong/webvideo-downloader/issues/128#issuecomment-1099816625):
Hi @ssettor, Thanks a lot for your reply! I edited the code and it can work now! Thank you so much!!! : )
In summary, just follow @enaskr 's code (#128 (comment) ). However, if it get some unicode error, please edit below (#128 (comment)):
- find 「myFile = open(vttFile, 'r')」 ,and change to => 「myFile = open(vttFile, 'r', encoding='utf-8')」
- find 「srtFile = open(srtFileName, 'a')」, and change to => 「open(srtFileName, 'a', encoding='utf-8')」
Hi @ChunlyShen
I have tried many times but it still cannot work. Would you please upload your dispatcher.py to any public free space, such as mega, GD,....etc ? Thanks a lot.
Hi @peedan Sure:(2022/4/30 Update link) https://drive.google.com/file/d/16Vu2AxbtRLsZeMlmRwZiJ8bSrBue-vxh/view?usp=sharing However, some videos can work, and some videos can't. I am still trying to find why.
I guess the problem gets from [.srt merge to .mp4].
I found [.srt merge to .mp4] get error reason, it because of "the subtitles file format".
For example:
When I download to get the error, the .srt file are saved to the temp folder.
I compare all [.srt] file content and found something different in the content.
Please see below the photo-A, the time format is 00:00.000
Please see below the photo-B, the time format is 00:00:00.000
There are [.srt] files that can work for the online player, however, the program "merger function(.srt merge to .mp4)" can't work for the time format of photo-A.
Therefore, solutions are two ways:
For number 2, my solution is: I only want to get the ["繁體" .srt file] and the format is 00:00:00.000, so I edit my code, please see below:
Finally, I can download the video successfully.
WeTV的字幕連結是錯的,所以下載合併後影片不會顯示字幕。請問有辦法修改嗎?謝謝。