bindestriche / srt_fix

yt-autosub-srt-fix a yt-dlp plugin to fix double lines of youtube subtitles converted to srt via ffmpeg
The Unlicense
22 stars 5 forks source link

i got this error #1

Closed fouda4ever closed 1 year ago

fouda4ever commented 1 year ago

Microsoft Windows [Version 10.0.19044.2364] (c) Microsoft Corporation. All rights reserved.

C:\yt-dlp>yt-dlp https://www.youtube.com/watch?v=fGl93wb5SKk Error while importing module 'yt_dlp_plugins.postprocessor.srt_fix' Traceback (most recent call last): File "C:\Users\Khaled\AppData\Roaming\yt-dlp\plugins\srt_fix\yt_dlp_plugins\postprocessor\srt_fix.py", line 84, in SimpleSrt def get_duration(parts: list[int, int, int, int]) -> timedelta: TypeError: 'type' object is not subscriptable Traceback (most recent call last): File "yt_dlp__main.py", line 17, in File "yt_dlp__init__.py", line 967, in main File "yt_dlp__init__.py", line 927, in _real_main File "yt_dlp\YoutubeDL.py", line 734, in init__ File "yt_dlp\postprocessor__init.py", line 42, in get_postprocessor KeyError: 'srt_fixPP' [15304] Failed to execute script 'main__' due to unhandled exception!

C:\yt-dlp>

bindestriche commented 1 year ago

Thank you for reporting. Please try again with updated version

fouda4ever commented 1 year ago

i go this

Microsoft Windows [Version 10.0.19044.2364] (c) Microsoft Corporation. All rights reserved.

C:\yt-dlp>yt-dlp https://www.youtube.com/watch?v=fGl93wb5SKk Error while importing module 'yt_dlp_plugins.postprocessor.srt_fix' Traceback (most recent call last): File "C:\Users\Khaled\AppData\Roaming\yt-dlp\plugins\srt_fix\yt_dlp_plugins\postprocessor\srt_fix.py", line 84, in SimpleSrt def get_duration(parts: list[int, int, int, int]) -> timedelta: TypeError: 'type' object is not subscriptable Traceback (most recent call last): File "yt_dlp__main.py", line 17, in File "yt_dlp__init__.py", line 967, in main File "yt_dlp__init__.py", line 927, in _real_main File "yt_dlp\YoutubeDL.py", line 734, in init__ File "yt_dlp\postprocessor__init.py", line 42, in get_postprocessor KeyError: 'srt_fixPP' [13256] Failed to execute script 'main__' due to unhandled exception!

bindestriche commented 1 year ago

Thank you for your patience, 2. update should work now

fouda4ever commented 1 year ago

the duplicate subs still there. i have this config --sub-lang de,de-DE,ar,en --convert-subs=srt --use-postprocessor srt_fix --write-subs --write-auto-subs --embed-subs --compat-options no-keep-subs

bindestriche commented 1 year ago

the duplicate subs still there.

I see you are embedding the subs. As of now, script generates a second SRT file that ends with .fixed.srt. The embed-subs option will not work right now.

I agree that I should make it work with embedding, but right now for debugging, can you tell we if the .fixed.srt exists and has the expected content? omit the no-keeps-subs option, so the files do not get deleted.

The command yt-dlp https://www.youtube.com/watch?v=fGl93wb5SKk --sub-lang de,de-DE,ar,en --convert-subs=srt --use-postprocessor srt_fix --write-subs --write-auto-subs , produces the situation below. If you use vlc player, the subtitle files will be loaded. I copied the de.fixed.srt to de_fixed.srt, so a useful name is displayed. I know this is not as good as having the subtitles right in the video file, but as of now I don't know how to make my code run before the embedding of the subtitles. grafik

fouda4ever commented 1 year ago

I edit the configuration, but srt.fix didn't get generated, only the original ones

bindestriche commented 1 year ago

You are using a config file? Please run yt-dlp -vU https://www.youtube.com/watch?v=fGl93wb5SKk --sub-lang de,de-DE,ar,en --convert-subs=srt --use-postprocessor srt_fix --write-subs --write-auto-subs and share the whole output

also delete the pycache folder in the plugin directory if there is one.

fouda4ever commented 1 year ago

it works, thanks for your time. Here is the output

Microsoft Windows [Version 10.0.19044.2364] (c) Microsoft Corporation. All rights reserved.

C:\yt-dlp>yt-dlp yt-dlp -vU https://www.youtube.com/watch?v=fGl93wb5SKk --sub-lang de,de-DE,ar,en --convert-subs=srt --use-postprocessor srt_fix --write-subs --write-auto-subs [debug] Command-line config: ['yt-dlp', '-vU', 'https://www.youtube.com/watch?v=fGl93wb5SKk', '--sub-lang', 'de,de-DE,ar,en', '--convert-subs=srt', '--use-postprocessor', 'srt_fix', '--write-subs', '--write-auto-subs'] [debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8 [debug] yt-dlp version stable@2023.03.04 [392389b7d] (win_exe) [debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19044-SP0 (OpenSSL 1.1.1k 25 Mar 2021) [debug] exe versions: ffmpeg 5.1.2-essentials_build-www.gyan.dev (setts), ffprobe 5.1.2-essentials_build-www.gyan.dev [debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4 [debug] Proxy map: {} [debug] Post-Processor Plugins: srt_fixPP [debug] Plugin directories: ['C:\Users\Khaled\AppData\Roaming\yt-dlp\plugins\srt_fix\yt_dlp_plugins'] [debug] Loaded 1786 extractors [debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest Available version: stable@2023.03.04, Current version: stable@2023.03.04 Current Build Hash: 5590c57bd0433ed239a2deaaf92e2ad6f37fe50f53664c821575cafe106a9421 yt-dlp is up to date (stable@2023.03.04) [CommonMistakes] Extracting URL: yt-dlp ERROR: [CommonMistakes] None: You've asked yt-dlp to download the URL "yt-dlp". That doesn't make any sense. Simply remove the parameter in your command or configuration. File "yt_dlp\extractor\common.py", line 694, in extract File "yt_dlp\extractor\commonmistakes.py", line 25, in _real_extract

[youtube] Extracting URL: https://www.youtube.com/watch?v=fGl93wb5SKk [youtube] fGl93wb5SKk: Downloading webpage [youtube] fGl93wb5SKk: Downloading android player API JSON [info] fGl93wb5SKk: Downloading subtitles: de, ar, en [debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto [debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id [debug] Default format spec: bestvideo*+bestaudio/best [info] fGl93wb5SKk: Downloading 1 format(s): 248+251 [info] Writing video subtitles to: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].de.vtt [debug] Invoking http downloader on "https://www.youtube.com/api/timedtext?v=fGl93wb5SKk&caps=asr&opi=112496729&xoaf=5&hl=en&ip=0.0.0.0&ipbits=0&expire=1683350857&sparams=ip%2Cipbits%2Cexpire%2Cv%2Ccaps%2Copi%2Cxoaf&signature=1C6DB508CC289C8275639E4A782A8BAA0133F6B2.8BD4BEE9990CBF2DDA0114B272A0DEF7B5CA06E5&key=yt8&kind=asr&lang=de&fmt=vtt" [debug] File locking is not supported. Proceeding without locking [download] Destination: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].de.vtt [download] 100% of 36.21KiB in 00:00:00 at 149.55KiB/s [info] Writing video subtitles to: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].ar.vtt [debug] Invoking http downloader on "https://www.youtube.com/api/timedtext?v=fGl93wb5SKk&caps=asr&opi=112496729&xoaf=5&hl=en&ip=0.0.0.0&ipbits=0&expire=1683350857&sparams=ip%2Cipbits%2Cexpire%2Cv%2Ccaps%2Copi%2Cxoaf&signature=1C6DB508CC289C8275639E4A782A8BAA0133F6B2.8BD4BEE9990CBF2DDA0114B272A0DEF7B5CA06E5&key=yt8&kind=asr&lang=de&tlang=ar&fmt=vtt" [download] Destination: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].ar.vtt [download] 100% of 30.65KiB in 00:00:00 at 97.33KiB/s [info] Writing video subtitles to: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].en.vtt [debug] Invoking http downloader on "https://www.youtube.com/api/timedtext?v=fGl93wb5SKk&caps=asr&opi=112496729&xoaf=5&hl=en&ip=0.0.0.0&ipbits=0&expire=1683350857&sparams=ip%2Cipbits%2Cexpire%2Cv%2Ccaps%2Copi%2Cxoaf&signature=1C6DB508CC289C8275639E4A782A8BAA0133F6B2.8BD4BEE9990CBF2DDA0114B272A0DEF7B5CA06E5&key=yt8&kind=asr&lang=de&tlang=en&fmt=vtt" [download] Destination: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].en.vtt [download] 100% of 35.14KiB in 00:00:00 at 138.37KiB/s [SubtitlesConvertor] Converting subtitles [debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].de.vtt" -f srt -movflags "+faststart" "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].de.srt" [debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].ar.vtt" -f srt -movflags "+faststart" "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].ar.srt" [debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].en.vtt" -f srt -movflags "+faststart" "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].en.srt" Deleting original file Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].ar.vtt (pass -k to keep) Deleting original file Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].en.vtt (pass -k to keep) Deleting original file Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].de.vtt (pass -k to keep) [debug] Invoking dashsegments downloader on "https://rr3---sn-uxaxjvhxbt2u-j5ped.googlevideo.com/videoplayback?expire=1683347258&ei=2oJVZMPjDsadvdIPibizuAI&ip=156.212.221.244&id=o-AMp61HYFg7k_RgU7LhxQfTfTVGivbqRE8nOoN2Lpw2KY&itag=248&source=youtube&requiressl=yes&mh=zG&mm=31%2C29&mn=sn-uxaxjvhxbt2u-j5ped%2Csn-hgn7yn7e&ms=au%2Crdu&mv=m&mvi=3&pl=23&initcwndbps=321250&spc=qEK7B2SV-4WC-F5CQfm1oTqqcjzTYgQ&vprv=1&svpuc=1&mime=video%2Fwebm&gir=yes&clen=82524426&dur=540.520&lmt=1677273512303422&mt=1683325271&fvip=4&keepalive=yes&fexp=24007246&c=ANDROID&txp=5319224&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAOvzfOUoUR1ffxoWUmijoAwnXV9PcJDgtDBOok4WzCZ5AiBJe6-WAz62tNPRxC0YdP1NQvXxXNdfMDTIRkV6lzQcKw%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhAO-xSbq-wqado2BQhyFkDIcxVMaeFyPqzHTd34LL_BSPAiAaF9KC16iHiIQPunKF2erBrS0N5HJBathLXJEdNccL3w%3D%3D" [dashsegments] Total fragments: 8 [download] Destination: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].f248.webm [download] 100% of 78.70MiB in 00:00:26 at 2.94MiB/s [debug] Invoking dashsegments downloader on "https://rr3---sn-uxaxjvhxbt2u-j5ped.googlevideo.com/videoplayback?expire=1683347258&ei=2oJVZMPjDsadvdIPibizuAI&ip=156.212.221.244&id=o-AMp61HYFg7k_RgU7LhxQfTfTVGivbqRE8nOoN2Lpw2KY&itag=251&source=youtube&requiressl=yes&mh=zG&mm=31%2C29&mn=sn-uxaxjvhxbt2u-j5ped%2Csn-hgn7yn7e&ms=au%2Crdu&mv=m&mvi=3&pl=23&initcwndbps=321250&spc=qEK7B2SV-4WC-F5CQfm1oTqqcjzTYgQ&vprv=1&svpuc=1&mime=audio%2Fwebm&gir=yes&clen=8428996&dur=540.541&lmt=1677273544317870&mt=1683325271&fvip=4&keepalive=yes&fexp=24007246&c=ANDROID&txp=5318224&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAK_7_tPgzveiBLZ3UcZuR9bCDpVQBRCM6b_W_I7perWDAiEA-NsAeVkq27VH9BKUcDyKKID2VLxkV3hKLghYldLKqnE%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhAO-xSbq-wqado2BQhyFkDIcxVMaeFyPqzHTd34LL_BSPAiAaF9KC16iHiIQPunKF2erBrS0N5HJBathLXJEdNccL3w%3D%3D" [dashsegments] Total fragments: 1 [download] Destination: Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].f251.webm [download] 100% of 8.04MiB in 00:00:02 at 3.23MiB/s [Merger] Merging formats into "Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].webm" [debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].f248.webm" -i "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].f251.webm" -c copy -map "0:v:0" -map "1:a:0" -movflags "+faststart" "file:Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].temp.webm" Deleting original file Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].f248.webm (pass -k to keep) Deleting original file Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].f251.webm (pass -k to keep) [srt_fix] post-processed 'Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].webm' with {} [srt_fix] applied srt_fix to Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].ar.srt saved as Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].fixed.srt [srt_fix] applied srt_fix to Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].de.srt saved as Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].fixed.srt [srt_fix] applied srt_fix to Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].en.srt saved as Can you keep up? | comprehensible TPRS Story for Intermediate German Beginners [fGl93wb5SKk].fixed.srt

xw5P24Oxin

bindestriche commented 1 year ago

@fouda4ever thank you for your time as well, what did you change?

fouda4ever commented 1 year ago

I deleted yt-dlp.conf file, and there wasn't a pycache folder in the plugin directory. Then run cmd with provided with

yt-dlp -vU https://www.youtube.com/watch?v=fGl93wb5SKk --sub-lang de,de-DE,ar,en --convert-subs=srt --use-postprocessor srt_fix --write-subs --write-auto-subs

My configuration file has change directory of downloads, when i remove this (-o ), it works with configuration file normal

bindestriche commented 1 year ago

thank you for the info, the path should be working. I will investigate this further

GunGunGun commented 1 year ago

Yeah, I can confirm if you use -o to specify output folder .fixed.format won't be generated.

And can you also make this script work with MPV+yt-dlp setup ?