diff --git a/LICENSE b/LICENSE index 4afcd78..454068b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2015-2018 Isaac Bernat +Copyright (c) 2015-2025 Isaac Bernat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index 4d801e2..b65790c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 1. [Get the subtitles](https://github.com/isaacbernat/netflix-to-srt#get-the-subtitles) (`.xml` dfxp or `.vtt` files from Netflix, YouTube... streaming media services). - [From Netflix](https://github.com/isaacbernat/netflix-to-srt#from-netflix) - [From YouTube](https://github.com/isaacbernat/netflix-to-srt#from-youtube) -2. [Convert them](https://github.com/isaacbernat/netflix-to-srt#convert-them-into-srt) into `.srt` files. +2. [Convert them](https://github.com/isaacbernat/netflix-to-srt#convert-them-into-srt) into `.srt` files (and/or shift timestamps). 3. [Star this repo ⭐](https://github.com/isaacbernat/netflix-to-srt#star-this-repo) ## Get the subtitles @@ -69,6 +69,7 @@ You need FireFox and AdblockPlus Add-On. *not tested on other browsers* - Copy your subtitle files in the same directory as `to_srt.py` - Or use `-i INPUT_PATH` and `-o OUTPUT_PATH` for custom file locations - All `.xml` and `.vtt` files in the input directory will generate a converted `.srt` file on the output one +- *Optional:* Use `-d DELAY_MS` parameter when running the script to delay all the timestamps by the given number of milliseconds. Negative values shift timestamps backwards. Example: `python to_srt.py -i samples/delays -o samples/delays -d -1500` will take all the eligible files in `samples/delays` and shift the subtitles to be 1.5 seconds earlier than the original version - Enjoy! (And **star the repo ⭐** if you liked it ;D) ## Star this repo @@ -84,7 +85,9 @@ If you like this project, please **star the repository ⭐**. It's free and it h - Thanks for your contribution! ## Why this repository? -VLC player could not reproduce that kind of xml subtitles and I could not find any tool that could easily transform the xml files to a suitable format (e.g. SubRip (`.srt`)) in Linux or Mac, so I wrote this script and decided to share. I got a request for WebVTT (`.vtt`) and did the same. +[VideoLAN's VLC media player](https://www.videolan.org/vlc/) could not reproduce that kind of xml subtitles and I could not find any tool that could easily transform the xml files to a suitable format (e.g. SubRip (`.srt`)) in Linux or Mac, so I wrote this script and decided to share. I got a request for WebVTT (`.vtt`) and did the same. + +Similarly, adjusting timestamps in 50ms increments was inconvenient using VLC's hotkeys (G, H and/or J) for large mismatches (e.g. 60 seconds because openings or summaries), so I added the `-d DELAY_MS` parameter so I could "advance" all the subtitles lines easily. ## TODOs - More robust file parsing than just some quick and dirty regexes. diff --git a/samples/delay/sample_vtt.vtt b/samples/delay/sample_vtt.vtt new file mode 100644 index 0000000..37bc324 --- /dev/null +++ b/samples/delay/sample_vtt.vtt @@ -0,0 +1,33 @@ +WEBVTT + +NOTE Netflix +NOTE Profile: webvtt-lssdh-ios8 +NOTE Date: 2019/11/27 21:10:46 + +NOTE SegmentIndex +NOTE Segment=591.758 7643@494 61 +NOTE Segment=596.513 12163@8137 99 +NOTE Segment=595.011 9765@20300 77 +NOTE Segment=597.430 8648@30065 68 +NOTE Segment=390.473 4112@38713 34 +NOTE /SegmentIndex + + + + +1 +00:01:15.450 --> 00:01:17.577 position:50.00%,middle align:middle size:80.00% line:84.67% +Que veux-tu ? + +2 +00:01:17.660 --> 00:01:21.247 position:50.00%,middle align:middle size:80.00% line:79.33% +Je veux savoir si une femme +montera sur le trône de Kattegat. + +3 +00:01:22.165 --> 00:01:24.250 position:50.00%,middle align:middle size:80.00% line:84.67% +Tu veux dire, après le décès de Ragnar ? + +4 +00:01:59.503 --> 00:02:00.629 position:50.00%,middle align:middle size:80.00% line:84.67% +Oui. diff --git a/samples/delay/sample_vtt_minus_900.srt b/samples/delay/sample_vtt_minus_900.srt new file mode 100644 index 0000000..f2c214b --- /dev/null +++ b/samples/delay/sample_vtt_minus_900.srt @@ -0,0 +1,17 @@ +1 +00:01:14,550 --> 00:01:16,677 +Que veux-tu ? + +2 +00:01:16,760 --> 00:01:20,347 +Je veux savoir si une femme +montera sur le trône de Kattegat. + +3 +00:01:21,265 --> 00:01:23,350 +Tu veux dire, après le décès de Ragnar ? + +4 +00:01:58,603 --> 00:01:59,729 +Oui. + diff --git a/samples/delay/sample_vtt_plus_900.srt b/samples/delay/sample_vtt_plus_900.srt new file mode 100644 index 0000000..114029b --- /dev/null +++ b/samples/delay/sample_vtt_plus_900.srt @@ -0,0 +1,17 @@ +1 +00:01:16,350 --> 00:01:18,477 +Que veux-tu ? + +2 +00:01:18,560 --> 00:01:22,147 +Je veux savoir si une femme +montera sur le trône de Kattegat. + +3 +00:01:23,065 --> 00:01:25,150 +Tu veux dire, après le décès de Ragnar ? + +4 +00:02:00,403 --> 00:02:01,529 +Oui. + diff --git a/samples/delay/sample_xml.xml b/samples/delay/sample_xml.xml new file mode 100644 index 0000000..9d29a93 --- /dev/null +++ b/samples/delay/sample_xml.xml @@ -0,0 +1,38 @@ + + + + + +