chenqingyu / auto-sub

Automatically exported from code.google.com/p/auto-sub
0 stars 0 forks source link

Last letter of filename is dropped #149

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. download subtitle for series Akta.Manniskor / Real Humans (all other shows 
work fine)

What is the expected output? What do you see instead?
I expect the filename to be (the same as the filename for of the videofile):
Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-ToK.srt
but it is:
Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-To.srt

So the last letter, 'K' has been removed from the file name as per notification 
mail:
AutoSub downloaded the following subtitle (language: nl):
 Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-To.srt 
For the videofile:
 Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-ToK.ts

What version of the product are you using? On what operating system?
5.5 beta and 5.6 alpha on freebsd

Please provide any additional information below.
Problem occurs for all epdisodes tried so far.
Is the issue maybe related to the last letter of the filename being in 
uppercase, and the one-but-last in lowercase?

Original issue reported on code.google.com by id2t...@hotmail.com on 9 Nov 2012 at 1:05

GoogleCodeExporter commented 9 years ago
I don't really get what goes wrong here. I justed tested it, and it works for 
me.

----BEGIN----
Hi,

AutoSub downloaded the following subtitle (language: nl):
 Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-ToK.srt

For the videofile:
 Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-ToK.mkv
----END----

What is the location on your file system (maybe directory name is too long?)?
Are you using any other notification?
Is the subtitle save correctly on your file system or does the real subtitle 
file also mist the last 'k'?

Original comment by romke.va...@gmail.com on 9 Nov 2012 at 6:21

GoogleCodeExporter commented 9 years ago
Hello Romke,

Thx for checking the issue.

The whole directory name is about 36 chars, so not very long.
I only use the autosub standard notification.
The real subtitle file also misses the last 'K' in the file.

I had a look at the code and the problem is caused by the fact the video file 
has an extension of 2 chars long, as it's 'TS' and the code in checkSub.py 
assumes the extension is always 3 characters long it seems.
Extensions with 3 chars work OK, like '.mkv' and '.mp4,' but '.TS' does not.

The following code-change fixes the issue:
auto-sub/autosub# diff checkSub.py.org checkSub.py
46c46
<                 srtfile = os.path.join(originalfile[:-4] + ".srt")
---
>                 srtfile = os.path.splitext(originalfile)[0] + ".srt"

Then I get:
AutoSub downloaded the following subtitle (language: nl):
 Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-ToK.srt 
For the videofile:
 Akta.Manniskor.S01E07.SWEDISH.720p.HDTV.H.264-ToK.ts

There are more places and files where the construction of '[:-4] + ".srt"' is 
used and maybe these need to be changed too.

I hope this helps.
Please feel free to contact me at id2test@hotmail.com for any more info or 
testing.

Kind regards, Ids.

Original comment by id2t...@hotmail.com on 10 Nov 2012 at 8:10

GoogleCodeExporter commented 9 years ago
A yeah, that explains a lot, that [:-4] has been there since the beginning of 
auto-sub, never caused a problem so never really paid attention to it. 

Thanks for your detail look, your fix as been implemented.

Original comment by romke.va...@gmail.com on 10 Nov 2012 at 8:54

GoogleCodeExporter commented 9 years ago
Hello Romke,

Thanks for the quick fix.

I had a look at the new code in source and saw the new code is:
os.path.splitext(originalfile)[0] + u".srt"

Are you sure this - the last part being '+ u".srt"' is correct?

And also; the fixed lines have the same content now, so no longer different for 
SUBNL, standard, and SUBENG like in the original source?

Please also note a similar fix needs to be implemented in files (which also use 
[:-4]) :
scanDisk.py
checkRss.py
This to prevent the srt file to be not found and downloaded over and over again 
as part of each check.

In which version is the fix intended to be included?

Below is a diff of the 3 files I think need to be modified.

Thx.
Regards, Ids.

------

auto-sub/autosub# diff checkSub.py.org checkSub.py
44c44
<                 srtfile = os.path.join(originalfile[:-4] + "." + 
autosub.SUBNL + ".srt")
---
>                 srtfile = os.path.splitext(originalfile)[0] + "." + 
autosub.SUBNL + ".srt"
46c46
<                 srtfile = os.path.join(originalfile[:-4] + ".srt")
---
>                 srtfile = os.path.splitext(originalfile)[0] + ".srt"
48c48
<             engsrtfile = os.path.join(originalfile[:-4] + "." + 
autosub.SUBENG + ".srt")
---
>             engsrtfile = os.path.splitext(originalfile)[0] + "." + 
autosub.SUBENG + ".srt"

auto-sub/autosub# diff scanDisk.py.org scanDisk.py
37c37
<                         srtfile = os.path.join(filename[:-4] + "." + 
autosub.SUBNL + ".srt")
---
>                         srtfile = os.path.splitext(filename)[0] + "." + 
autosub.SUBNL + ".srt"
39c39
<                         srtfile = os.path.join(filename[:-4] + ".srt")
---
>                         srtfile = os.path.splitext(filename)[0] + ".srt"
41c41
<                     srtfileeng = os.path.join(filename[:-4] + "." + 
autosub.SUBENG + ".srt")
---
>                     srtfileeng = os.path.splitext(filename)[0] + "." + 
autosub.SUBENG + ".srt"

auto-sub/autosub# diff checkRss.py.org checkRss.py
154c154
<                                 srtfile = os.path.join(originalfile[:-4] + 
"." + autosub.SUBNL + ".srt")
---
>                                 srtfile = os.path.splitext(originalfile)[0] + 
"." + autosub.SUBNL + ".srt"
156c156
<                                 srtfile = os.path.join(originalfile[:-4] + 
".srt")
---
>                                 srtfile = os.path.splitext(originalfile)[0] + 
".srt"
159c159
<                                 srtfile = os.path.join(originalfile[:-4] + 
"." + autosub.SUBENG + ".srt")
---
>                                 srtfile = os.path.splitext(originalfile)[0] + 
"." + autosub.SUBENG + ".srt"
161c161
<                                 srtfile = os.path.join(originalfile[:-4] + 
".srt")
---
>                                 srtfile = os.path.splitext(originalfile)[0] + 
".srt"

Original comment by id2t...@hotmail.com on 11 Nov 2012 at 10:03

GoogleCodeExporter commented 9 years ago
Hi, thanks for point out the mistake. Yeah indeed, I forgot to add the subnl 
etc stuff.
the  u".srt" part is correct, because all the config settings are unicode. 
Thanks god that python allows combining string with unicode string without a 
problem. But it is 'nicer' just to combine the right types :)

Thanks again, I hope my last push fixes this issue completely 

Original comment by romke.va...@gmail.com on 11 Nov 2012 at 11:47

GoogleCodeExporter commented 9 years ago
Ow, and this fix will be implemented in next major release. So the upcoming 
0.5.6 beta. Which you can expect is about a week time.

Original comment by romke.va...@gmail.com on 11 Nov 2012 at 11:48

GoogleCodeExporter commented 9 years ago
Hello Romke,

Thanks for the reply.

It seems there are still 2 incorrect updates - note the last line each time 
below where string autosub.SUBNL is added to the english srt filename - in 
files checkSub.py and scanDisk.py:

checkSub.py now contains:
            if autosub.SUBNL != "":
                srtfile = os.path.splitext(originalfile)[0] + u"." + autosub.SUBNL + u".srt"
            else:
                srtfile = os.path.splitext(originalfile)[0] + u".srt"

            engsrtfile = os.path.splitext(originalfile)[0] + u"." + autosub.SUBNL + u".srt"

I think this should be:
            if autosub.SUBNL != "":
                srtfile = os.path.splitext(originalfile)[0] + u"." + autosub.SUBNL + u".srt"
            else:
                srtfile = os.path.splitext(originalfile)[0] + u".srt"

            engsrtfile = os.path.splitext(originalfile)[0] + u"." + autosub.SUBENG + u".srt"

scanDisk.py now contains:
                    if autosub.SUBNL != "":
                        srtfile = os.path.splitext(filename)[0] + u"." + autosub.SUBNL + u".srt"
                    else:
                        srtfile = os.path.splitext(filename)[0] + u".srt"

                    srtfileeng = os.path.splitext(filename)[0] + u"." + autosub.SUBNL + u".srt"

I think this should be:
                    if autosub.SUBNL != "":
                        srtfile = os.path.splitext(filename)[0] + u"." + autosub.SUBNL + u".srt"
                    else:
                        srtfile = os.path.splitext(filename)[0] + u".srt"

                    srtfileeng = os.path.splitext(filename)[0] + u"." + autosub.SUBENG + u".srt"

Regards, Ids.

Original comment by id2t...@hotmail.com on 11 Nov 2012 at 5:16

GoogleCodeExporter commented 9 years ago
Thanks again,

Kinda busy today and don't really have time to look at auto-sub, so thanks for 
keeping an eye out. Hope it is fixed this time :)

Many thanks

Original comment by romke.va...@gmail.com on 11 Nov 2012 at 5:51