emericg / OpenSubtitlesDownload

Automatically find and download the right subtitles for your favorite videos!
https://emeric.io/OpenSubtitlesDownload
GNU General Public License v3.0
579 stars 63 forks source link

type 'exceptions.UnicodeDecodeError' #72

Closed AllKind closed 3 years ago

AllKind commented 3 years ago
~/.local/share/nemo/scripts/OpenSubtitlesDownload.py ~/Videos/Guardians.2017.1080p.BluRay.x264.mkv 
Unexpected error (line 786): <type 'exceptions.UnicodeDecodeError'>

Returns a long list if --cli is used. Something in the result list triggers the error for gnome gui result display.

System: Linux Mint 19.3

emericg commented 3 years ago

Are you using the version from the git master? That line triggering an error is a bit unexpected indeed. Also are you using python3, and is this error happening for every file with the GUI?

AllKind commented 3 years ago

Yes, using the git master version.

ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       7 Aug  6  2019 /usr/bin/python -> python2
lrwxrwxrwx 1 root root       9 Aug  6  2019 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3633000 Feb 27 16:10 /usr/bin/python2.7
lrwxrwxrwx 1 root root      33 Feb 27 16:10 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 Aug  6  2019 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 Feb 21  2020 /usr/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 4526456 Jan 26 16:33 /usr/bin/python3.6

I see standard is python 2. This throws the error. Running it with python3 is working. This is the first time I encountered the error.

AllKind commented 3 years ago

python /usr/local/bin/OpenSubtitlesDownload.py --cli /storage/pub/video/inbox/movie/Guardians.2017.1080p.BluRay.DTS.5.1.x264.NLSubs/Guardians.2017.1080p.BluRay.x264.mkv

Title: Guardians of the Galaxy Vol. 2 Filename: Guardians.2017.1080p.BluRay.x264.mkv Available subtitles: [1] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BluRay.x264-SPARKS.srt" [2] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BluRay.x264-SPARKS-HI.srt" > "HI" [3] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BluRay.x264-SPARKS.srt" [4] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BluRay.x264-SPARKS.HI.srt" > "HI" [5] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BRRip.MKvCage.eng.srt" [6] "Game.Of.Thrones.Conquest.Rebellion.An.Animated.History.Of.The.Seven.Kingdoms.2017.1080p.Bl.srt" > "HI" [7] "Guardians.of.the.Galaxy.Vol.2.2017.1080p.BluRay.H264.AAC-RAR.srt" [8] "Guardians.of.the.Galaxy.Vol.2.2017.UHD.BluRay.2160p.TrueHD.Atmos.7.1.HEVC.REMUX-FraMeSToR.srt" [9] "Guardians of the Galaxy Vol 2 (2017).BDRip_BluRay-SPARKS.HI.srt" > "HI" [10] "The.Guardians.2017.RUSSIAN.1080p.BluRay.x264.DTS-FGT.srt" [11] "Guardians.of.the.Galaxy.Vol.2.2017.1080p-720p.BluRay-BRRip.srt" [12] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BluRay.x264-SPARKS.srt" [13] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BluRay.x264-SPARKS.srt" [14] "12.Monkeys.S03E02.BDRip.X264-DEFLATE.srt" [15] "Game.of.Thrones.Conquest.and.Rebellion.2017.1080p.6CH.BluRay.x265-HETeam.srt" [16] "Les.Gardiennes.2017.FRENCH.1080p.BluRay.x264-LOST.srt" [17] "Game.of.Thrones.Conquest.and.Rebellion.2017.1080p.BluRay.x264-.YTS.PE.srt" [18] "The.Guardians.2017.BluRay.Remux.1080p.AVC.DTS-HD.MA.5.1-HDH_SDH.srt" > "HI" [19] "12 Monkeys - S03E02 - Guardians [Bluray-1080p].en.srt" [20] "The.Guardians.2017.BluRay.Remux.1080p.AVC.DTS-HD.MA.5.1-HDH.srt" [21] "The.Guardians.2017.BDRip.x264-DEPTH.srt" [22] "The.Guardians.2017.RUSSIAN.720p.BluRay.x264.DTS-FGT.srt" [23] "Guardians.of.The.Galaxy.Vol.2.2017.BDRip.x264-SPARKS.srt" [24] "The.Guardians.2017.720p.BluRay.x264-SADPANDA.srt" [25] "Guardians.of.the.Galaxy.Vol.2.2017.1080p.BluRay.H264.AAC-RARBG.srt" [26] "The.Guardians.2017.720p.BluRay.x264-DEPTH -HI.srt" > "HI" [27] "The.Guardians.2017.720p.BluRay.x264-SADPANDA-HI.srt" > "HI" [28] "Guardians.of.the.Galaxy.Vol.2.2017.720p.WEB-DL.H264.AC3-EVO.srt" [29] "Zashchitniki.2017.O.WEB-DLRip.AVC.ExKinoRay.srt" [30] "Rabbit.School.Guardians.of.the.Golden.Egg.2018.HDRip.XviD.AC3-EVO.srt" [31] "Rabbit.School.Guardians.of.the.Golden.Egg.2018.HDRip.XviD.AC3-EVO-HI.srt" > "HI" [32] "GUARDIANS OF THE GALAXY VOL. 2 (2017) _NEW_HDCAM_x264_HQMic-CPG .srt" [33] "12.Monkeys.S03E02.Guardians.1080p.AMZN.WEBRip.DD+5.1.x264-VLAD.en.srt" [34] "12.Monkeys.S03E02.Guardians.1080p.AMZN.WEBRip.DD+5.1.x264-VLAD.en.srt" [35] "Guardians of the Galaxy Vol.2 (2017).srt" > "HI" [36] "12.Monkeys.S03E02.HDTV.x264-SVA.srt" [37] "Guardians.of.the.Galaxy.VOL-2.201.720p.HDRip.x264.AAC-Ozlem.srt" > "HI" [38] "Guardians of the Galaxy Vol 2 2017 HDTC LKRG.srt" [39] "Guardians of the Galaxy Vol. 2 (2017) English HDRip - 720p - x264 - AAC.srt" [40] "Marvels.Guardians.of.the.Galaxy.S02E04.Free.Bird.720p.DSNY.WEBRip.AAC2.0.x264-TVSmash.srt" [41] "Marvels.Guardians.of.the.Galaxy.S02E09.Right.Place.Wrong.Ti.srt" [42] "Marvel's Guardians of the Galaxy - 02x01 - Stayin' Alive.DSNY WEBRip TVSmash.srt" [43] "12.Monkeys.S03E02.HDTV.x264-SVA.HI.srt" > "HI" [44] "Guardians.of.the.Galaxy.S02E03 - Lyin' Eyes.HDTV.x264-BRISK.srt" [45] "Marvels.Guardians.of.the.Galaxy.S02E07.Right.Place.Wrong.Time.720p.DSNY.WEBRip.AAC2.0.x264.srt" [46] "Marvels.Guardians.of.the.Galaxy.S02E08.Me.and.You.and.a.Dog.Named.Cosmo.720p.DSNY.WEBRip.A.srt" [47] "Marvels.Guardians.of.the.Galaxy.S02E06.Black.Helmet.Woman.720p.DSNY.WEBRip.AAC2.0.x264-TVSmash.srt" [48] "Marvel's Guardians of the Galaxy - 02x02 - Evolution Rock.WEB-DL.x264.AAC.HI.srt" > "HI" [49] "Marvels.Guardians.of.the.Galaxy.S02E05.Girls.Just.Wanna.Have.Fun.720p.DSNY.WEBRip.AAC2.0.x.srt" [50] "Guardians.of.the.Galaxy.S02E05.Free.Bird.720p.WEB-DL.DD5.1.H.264-YFN.HI.srt" > "HI" [51] "Marvel's.Guardians.of.the.Galaxy.S02E15.Knights.in.Black.Helmets.720p.WEBRip.2CH.x265.HEVC-PSA.srt" > "HI" [52] "Marvel's.Guardians.of.the.Galaxy.S02E16.Nova.Me.Nova.You.720p.WEBRip.2CH.x265.HEVC-PSA.srt" > "HI" [53] "Marvels.Guardians.of.the.Galaxy.S02E10.Rock.Your.Baby.720p.DSNY.WEBRip.AAC2.0.x264.srt" [54] "Marvel's.Guardians.of.the.Galaxy.S02E14.Back.in.Black.720p.WEBRip.2CH.x265.HEVC-PSA.srt" > "HI" [55] "Guardians.of.the.Galaxy.S02E02 - Evolution Rock.HDTV.x264-W4F.srt" [56] "12.monkeys.s03e02.1080p.web.hevc.x265.rmteam.srt" [57] "Marvel's.Guardians.of.the.Galaxy.S02E17.Mr.Roboto.720p.WEBRip.2CH.x265.HEVC-PSA.srt" > "HI" [58] "Marvels.Guardians.of.the.Galaxy.S02E19.You.Cant.Always.Get.What.You.Want.720p.DSNY.WEB-DL..srt" [59] "Guardians.of.the.Galaxy.S02E11 - Symbiote War Part One_Wild World.HDTV.x264-W4F.srt" [60] "Marvel's Guardians of the Galaxy - 02x01 - Stayin' Alive.DSNY WEBRip TVSmash..srt" > "HI" [61] "Marvels.Guardians.of.the.Galaxy.S02E05.Girls.Just.Wanna.Have.Fun.720p.DSNY.WEBRip.AAC2.0.x.srt" > "HI" [62] "Marvels.Guardians.of.the.Galaxy.S02E06.Black.Helmet.Woman.720p.DSNY.WEBRip.AAC2.0.x264-TVS.srt" > "HI" [63] "Guardians.of.the.Galaxy.S02E18 - Destroyer.WEBRip.XviD.MP3-RARBG.srt" [64] "Guardians.of.the.Galaxy.S02E05.Free.Bird.720p.WEB-DL.DD5.1.H.264-YFN.srt" [65] "Marvels.Guardians.of.the.Galaxy.S02E09.720p.DSNY.WEBRip.AAC2.srt" > "HI" [66] "Marvels.Guardians.of.the.Galaxy.S02E01.Stayin.Alive.720p.DSNY.WEBRip.AAC2.0.x264-TVSmash.srt" [67] "Guardians of the Galaxy.S02E21 - I have seen all Good People.WEB-DL.x264 - HI.srt" > "HI" [68] "Marvels.Guardians.of.the.Galaxy.S02E10.Rock.Your.Baby.720p.DSNY.WEBRip.AAC2.0.x264 - HI.srt" > "HI" [69] "Guardians of the Galaxy.S02E23 - Its Tricky.WEB-DL.x264.AAC - HI.srt" > "HI" [70] "Marvels.Guardians.of.the.Galaxy.S02E04.Free.Bird.720p.DSNY.WEBRip.AAC2.0.x264-TVSmash-HI.srt" > "HI" [71] "Guardians.of.the.Galaxy.S02E12 - Symbiote War Part Two_I Will Survive.720p.HDTV.x264-W4F-HI.srt" > "HI" [72] "Guardians.of.the.Galaxy.S02E11 - Symbiote War Part One_Wild World.HDTV.x264-W4F - HI.srt" > "HI" [73] "Marvels.Guardians.of.the.Galaxy.S02E08.Me.and.You.and.a.Dog.Named.Cosmo.720p.DSNY.WEBRip.A.srt" > "HI" [74] "Guardians.of.the.Galaxy.S02E13 - Symbiote War- Part Three_Thunder Road.720p.HDTV.x264-W4F-HI.srt" > "HI" [75] "Guardians.of.the.Galaxy.S02E12 - Symbiote War Part Two_I Will Survive.720p.HDTV.x264-W4F.srt" [76] "Marvels.Guardians.of.the.Galaxy.S02E07.Right.Place.Wrong.Time.720p.DSNY.WEBRip.AAC2.0.x264.srt" > "HI" [77] "Guardians.of.the.Galaxy.S02E13 - Symbiote War- Part Three_Thunder Road.720p.HDTV.x264-W4F.srt" [78] "Guardians of the Galaxy.S02E21 - I have seen all Good People.WEB-DL.x264-m.srt" [79] "Guardians of the Galaxy.S02E23 - Its Tricky.WEB-DL.x264.AAC - m.srt" [80] "Marvel's.Guardians.of.the.Galaxy.S02E17.Mr.Roboto.720p.WEBRip.2CH.x265.HEVC-PSA - m.srt" [81] "Marvels.Guardians.of.the.Galaxy.S02E19.You.Cant.Always.Get.What.You.Want.720p.DSNY.WEB-DL..srt" > "HI" [82] "Marvels.Guardians.of.the.Galaxy.S02E10.Right.Place.Wrong.Time.720p.DSNY.WEBRip.AAC2.0.x264.srt" [83] "Marvels.Guardians.of.the.Galaxy.S02E10.Right.Place.Wrong.Time.720p.DSNY.WEBRip.AAC2.0.x264.srt" > "HI" [84] "Guardians.of.the.Galaxy.S02E18 - Destroyer.WEBRip.XviD.MP3-RARBG - HI.srt" > "HI" [85] "Cyborg.009.Call.of.Justice.S01E04.1080p.NF.WEB-DL.DD2.0.x264-QOQ.srt" [86] "[TorrentCounter.cc].The Guardians - Full.srt" [87] "Guardians.of.the.Galaxy.Vol.2.2017.720p.HDTC.srt" [88] "Zashchitniki.2017.1080p.720p.WEB-DL.x265.HEVC.Crazy4ad[crazy4tv.com].srt" [89] "Guardians of the Galaxy Vol. 2 (2017).en.srt" [90] "Guardians of the Galaxy Vol. 2 (2017) 1080pWEB-DLFull.srt" [91] "Marvel's Guardians of the Galaxy - 02x12 - Symbiote War Part Two - I Will Survive.WEB-DL..srt" [92] "Marvel's Guardians of the Galaxy - 02x13 - Symbiote War Part Three - Thunder Road.WEB-DL..srt" [93] "12.Monkeys.S03E02_eng.srt" [94] "The.Guardians.2017.RUSSIAN.1080p.WEB-DL.H264.DD5.1-FGT.en.srt" [95] "Guardians.of.the.Galaxy.Vol.2.2017.720p.HDTC.srt" [96] "The.Guardians.2017.RUSSIAN.1080p.WEB-DL.H264.DD5.1-FGT.srt" > "HI" [97] "The.Guardians.2017.RUSSIAN.1080p.WEB-DL.H264.DD5.1-FGT non hi.srt" [98] "Marvel's Guardians of the Galaxy.03x08.WEB-DL.x264.AAC.srt" [99] "Marvel's Guardians of the Galaxy.03x09.WEB-DL.x264.AAC.srt" [100] "Zashchitniki.2017.1080p.WEB-DL.Rus.HDCLUB.srt" [101] "Guardians of the galaxy 2.srt" [102] "Guardians.of.the.Galaxy.Vol.2.2017.720p.BluRay.x264-SidBrothers_3.srt" > "HI" [103] "Cyborg.009.Call.of.Justice.S01E04.1080p.Netflix.WEB-DL.DD+2.0.x264-QOQ.srt" > "HI" [104] "12 Monkeys - S03E02 - Guardians.srt" [105] "Zashchitniki.2017.1080p.WEB-DL.Rus.HDCLUB.srt" [0] Cancel search Enter your choice (0-105):

But then: python /usr/local/bin/OpenSubtitlesDownload.py --cli /storage/pub/video/inbox/movie/Guardians.2017.1080p.BluRay.DTS.5.1.x264.NLSubs/Guardians.2017.1080p.BluRay.x264.mkv > ~/Documents/guard.txt

cat ~/Documents/guard.txt [...] [88] "Zashchitniki.2017.1080p.720p.WEB-DL.x265.HEVC.Crazy4ad[crazy4tv.com].srt" [89] "Guardians of the Galaxy Vol. 2 (2017).en.srt" Unexpected error (line 789): <type 'exceptions.UnicodeEncodeError'>

emericg commented 3 years ago

Ok I'll have a quick look at this but actually this made me think about something, I'm just gonna remove python2 support alltogether for the next release. I'll probably do one last release compatible with python2 too.

I still try the script with python2 sometimes in order to keep it working, but some bugs stays hidden because not many people still uses it, and maintaining support for v2 and 3 is an unecessary burden now. Python 2 is long dead, I believe it is time.

AllKind commented 3 years ago

Yes I understand. I just wanted to give you more information. For me the problem is solved. I just replaced the executable in nemos script directory with a simple bash script, which calls the downloader with python3.

emericg commented 3 years ago

You were right to open a bug, this needed to be fixed (and actually thanks to the infos you provided, now it is :). One of the subtitles name had a utf8 space (?) inside, and that was causing python 2 (which is not great with utf8) to fail. Also to run the script with python 3 you can just edit the first line of the script and add a '3'.

!/usr/bin/env python3

emericg commented 3 years ago

This commit solves the python 2 issue, and will become the version 4.2, last one to support python 2.

https://github.com/emericg/OpenSubtitlesDownload/blob/cb5524559ae5f30b7512fad97eebc9a214cd862e/OpenSubtitlesDownload.py