webvideo-downloader icon indicating copy to clipboard operation
webvideo-downloader copied to clipboard

subtitle wetv now vtt

Open chathos opened this issue 2 years ago • 5 comments

vtt subtitles not downloading and mux error

chathos avatar Mar 10 '22 12:03 chathos

can confirm it. it started yesterday

Sparh4wk avatar Mar 11 '22 07:03 Sparh4wk

Yeah I have been able to download the videos but not the subtitles embedded

maradonaz avatar Mar 13 '22 06:03 maradonaz

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

`

enaskr avatar Apr 09 '22 06:04 enaskr

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

`

@enaskr enaskr

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.

peedan avatar Apr 18 '22 15:04 peedan

我修复了这个问题。但我的来源是肮脏的。我只学习了10天python。这是 dispatcher.py 的一部分。我只确认了WeTV和爱奇艺。

@enaskr (https://github.com/enaskr)

你能分享一下完整的dispatcher.p代码嘛?

NewRat97117 avatar Jun 04 '22 12:06 NewRat97117

vtt problem fixed by 9bcd04019a65a4dd8ccf377f9b2d354831b50b97

jaysonlong avatar Feb 08 '23 02:02 jaysonlong