0x776b7364 / toggle.sg-download

Python script to automate Toggle.sg video downloads
MIT License
26 stars 18 forks source link

subtitle renaming #43

Open SwedishGojira opened 6 years ago

SwedishGojira commented 6 years ago

Most apps will not pick up the subtitles associated with the video as the videos and the subtitle have different names. You should rename the subtitle to match the name of the video downloaded.

0x776b7364 commented 6 years ago

You're right. My impression is that players like VLC will display subtitles only if the subtitle filename matches the video filename (excluding the extension of course). Consider the case where a video has multiple subtitle files available (usually English and Mandarin), and this makes the program a little more complex. A user may prefer English subs, but if Eng is not available and Chi is, do you still want the Chi subs? I've considered that subtitle files don't take up much space (and so downloading all subtitle files are acceptable), and that a user can easily either drag-and-drop the preferred subtitle file into VLC, or manually rename the subtitle file to fit the video file.

As a sidenote, the "name of the video downloaded" is not immediately apparent from the response from the server - refer to issue #21 for an example of post-processing which was done on the video filename.

As always, let me know your preferred pseudocode to handle your use case, and we'll see if I (or anybody out there, including you) can do a PR.

SwedishGojira commented 6 years ago

Most videoplayers accept the subtitle if the filename is the same with added countrycode. if the video is named "video.mp4" the English subs would be "video.en.srt", malay subs would be "video.my.srt" and chinese "video.cn.srt".

Also I understand that the name of the video is very inconsistent, but if you get the video first, then store the filename you should be able to use that to rename the subs after you get them. At least that way the videos and subs will match.

0x776b7364 commented 6 years ago

Interesting - which videoplayers accept multiple subtitles based on the format you've described? If you can provide a Toggle video URL with both EN and CN subtitles available, I can look into integrating the requested functionality.

SwedishGojira commented 6 years ago

VLC, Kodi, Plex are some that I know about. MediaPlayer Classic support this also in Windows, but it all depends on what codecs you have installed. I use Kodi for my HTPC setup. This video has both EN and CN subs: https://video.toggle.sg/en/series/yes-mdm/ep9/436443 Not many that also have MY subs, but I know I did get it somewhere when I downloaded a show earlier from Toggle but never kept them as I only use English subs.

SwedishGojira commented 6 years ago

Sorry, I got the country-codes wrong. They should be EN for english, ZH for Chinese and MS for Malay (They don't have to be capital letters). See the two letter codes here: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

If you have a video named Test.mp4 and add subtitles Test.en.srt, Test.zh.srt and Test.ms.srt VLC will show them all as selectable subtitle-tracks under the Subtitle menu and show the languages accordingly. Same for Kodi and Plex.

jerryloh98 commented 4 years ago

Also the video naming also weird. For example my show is loving you but the naming only shows like this: Loving_You__hlstv_hd.mp4