ukdtom / SRT2UTF-8.bundle

Plex Agent, that'll convert sidecar subtitle files into UTF-8, if not
126 stars 14 forks source link

Add pt-BR #36

Closed duramato closed 6 years ago

duramato commented 6 years ago

I don't know if this actually fixes: https://github.com/ukdtom/SRT2UTF-8.bundle/issues/11#issuecomment-365655819

ukdtom commented 6 years ago

Why, when PMS itself doesn't recognize it? It comes in as pt

duramato commented 6 years ago

Plex supports IETF codes it seems, and in this case pt-BR

$ ls -lh The.Grand.Tour.S02E10.Oh.Canada.1080p.*.srt
-rwxrwxrwx 1 pi pi 93K Fev 16 07:33 The.Grand.Tour.S02E10.Oh.Canada.1080p.en.srt
-rwxrwxrwx 1 pi pi 87K Fev 16 07:34 The.Grand.Tour.S02E10.Oh.Canada.1080p.pt-BR.srt

image (External SRT)

ukdtom commented 6 years ago

I'll have to refuse this, but.... There's good news ;)

It's been a long time since I last shared some love to SRT2UTF-8, but decided now was the time.

As such, I changed a few things in it, as well as PEP8 enabled it.

Doing so, your PR would not merge, and also, you didn't add the needed lines alphabetically, which I want, so it's a tad more easy to locate.

But, and here's the good news....

I added it, and would like for you to confirm it's working as expected, but do note, that the preferred language in the settings of the channel has not been updated, since I pull that from PMS, and they do not support Brazilian Portuguese. As such, set that to Portuguese.

And to test, look here, and do remember to provide a feedback, so I can promote it to master branch

https://github.com/ukdtom/SRT2UTF-8.bundle/archive/tommy-work.zip

ukdtom commented 6 years ago

Ping

duramato commented 6 years ago

Just gave it a try:

2018-02-24 21:54:41,438 (70eff460) :  DEBUG (__init__:390) - Checking if file Homeland.S07E02.Rebel.Rebel.1080p.WEB-DL.h264-NTb.pt-BR.srt is valid
2018-02-24 21:54:41,440 (70eff460) :  DEBUG (__init__:411) - Found a valid subtitle file named "Homeland.S07E02.Rebel.Rebel.1080p.WEB-DL.h264-NTb.pt-BR.srt"
2018-02-24 21:54:41,598 (70eff460) :  DEBUG (__init__:150) - Chared is not supported, reverting to Beautifull Soap
2018-02-24 21:54:41,599 (70eff460) :  DEBUG (__init__:243) - BSFile to encode is /media/ssd/Shows/Homeland/Season 07/Homeland.S07E02.Rebel.Rebel.1080p.WEB-DL.h264-NTb.pt-BR.srt and filename language is xx
2018-02-24 21:54:41,706 (70eff460) :  DEBUG (__init__:250) - BeautifulSoup reports encoding as windows-1252
2018-02-24 21:54:41,708 (70eff460) :  DEBUG (__init__:297) - ******* SNIFF *******
2018-02-24 21:54:41,709 (70eff460) :  DEBUG (__init__:297) - We do not know the default encodings for xx
2018-02-24 21:54:41,710 (70eff460) :  DEBUG (__init__:297) - If you know this, then please go here: https://forums.plex.tv/discussion/94864 and tell me
2018-02-24 21:54:41,712 (70eff460) :  DEBUG (__init__:446) - Making a backup of /media/ssd/Shows/Homeland/Season 07/Homeland.S07E02.Rebel.Rebel.1080p.WEB-DL.h264-NTb.pt-BR.srt as /media/ssd/Shows/Homeland/Season 07/Homeland.S07E02.Rebel.Rebel.1080p.WEB-DL.h264-NTb.pt-BR.srt.Srt2Utf-8
2018-02-24 21:54:41,764 (70eff460) :  DEBUG (__init__:217) - Converting file: /media/ssd/Shows/Homeland/Season 07/Homeland.S07E02.Rebel.Rebel.1080p.WEB-DL.h264-NTb.pt-BR.srt with the encoding of windows-1252 into utf-8
2018-02-24 21:54:41,782 (70eff460) :  INFO (__init__:230) - Successfully converted /media/ssd/Shows/Homeland/Season 07/Homeland.S07E02.Rebel.Rebel.1080p.WEB-DL.h264-NTb.pt-BR.srt to utf-8 from windows-1252
2018-02-24 21:54:41,787 (70eff460) :  DEBUG (model:229) - Serializing to /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Metadata/TV Shows/d/a694f9e2f634abed625070e7ca659183bba08ab.bundle/Contents/com.plexapp.agents.srt2utf8/Info.xml
ukdtom commented 6 years ago

I'll take that as a go

Now just need to get rid of the log entry about xx and tell me ;)

ukdtom commented 6 years ago

And you should set default lang in the settings to Portuguese

duramato commented 6 years ago

But my subtitles aren't all in Portuguese, won't setting it to Portuguese mess things up?

ukdtom commented 6 years ago

Isn't Portuguese and pt-BR using the same encodings?

And if so, then you'll not mess up things

ukdtom commented 6 years ago

And merged into Master

This is now live :)

duramato commented 6 years ago

I also have English subtitles for example.

ukdtom commented 6 years ago

Should not matter....

ukdtom commented 6 years ago

The prefs settings goes for the following:

srt files, that do not have a language setting in their names, and encoding can not be determined, then it as the last fallback, resolves to the setting.

And when said, it's STRONGLY advised to use the language code in the srt name! (Not doing so, makes clients show srt language as unknown as well)

ukdtom commented 6 years ago

And adding here....

I know you have the lang code in place for the files, but why not also use the tailback option?