chenqingyu / auto-sub

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

Support for devices that do not support show.<lang>.srt #53

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using 2 somewhat older mediaplayers (HDX-1000 / PCH-A100) that do not 
support the language prefixes in the SRT name (like <showname>.nl.srt), but can 
only handle <showname.srt>.

However, I do like to have Dutch SRT when available and English SRT as long as 
Dutch is not available yet. 

What I would like to see is to have autosub copy the .en.srt file to .srt and 
as soon as the .nl.srt is available copy the .nl.srt to .srt. This way, these 
mediaplayers will have the 'best available' sub in the .srt file. 
The nl.srt and eng.srt will then also still be there (i.e. for other media 
players) and also since they are used for determining which versions are 
already downloaded.

I'm not a coder, but with some effort I've built in this into my  
downloadsub.py by adding this code (and an additional parameter 
'langsrtsupport=false' in config.properties) which now works great for me. 
I was wondering if you could consider implementing something like this into the 
current build as well.

configuration.properties :
# Set to false when your mediaplayer does NOT support language prefix
# in SRT name (like <showname>.nl.srt). Default: true
# Note : Both subeng and subnl must be non-empty for this to work.
langsrtsupport = false

--
downloadsub.py :

                    log.info("downloadSubs: DOWNLOADED: %s" % destsrt)

#---->
                    # copy <lang>.srt to .srt so the .srt file will contain 'best available' srt
                    if (not autosub.LANGSRTSUPPORT ):
                        splitname = destsrt.split(".")
                        lang=splitname[len(splitname)-2]
                        # sanity check. Only copy when encountering a valid language prefix
                        if (lang == autosub.SUBNL or lang == autosub.SUBENG):
                            del splitname[len(splitname)-2]
                            srtname=".".join(splitname)
                            log.info("downloadSubs: Copying language %s sub to generic SRT file %s as well." % (lang, srtname))
                            try:
                                shutil.copy2(destsrt,srtname)
                            except:
                                log.error("downloadSubs: Error copying file.")
                                continue
--

Original issue reported on code.google.com by Simon.Ve...@gmail.com on 20 Feb 2012 at 7:36

GoogleCodeExporter commented 9 years ago
This might sound as a quick fix, but after doodling this out on my whiteboard I 
came to the conclusion that it is not yet possible. Let me explain why:
AutoSub check if there is a subtitle needed for a video file by search the root 
directy for AVI files. Then check if the avi file has a subtitle file with the 
same name example:
Show.Name.S01E01.avi (does this file have Show.Name.S01E01.srt?) if not added 
this show to our wanted list.

Now lets say, there is no dutch subtitle available for Show.Name.S01E01. 
AutoSub download in your scenario a english subtitle as Show.Name.S01E01.srt. 
When autosub runs a new scan it sees that Show.Name.S01E01.avi has a subtitle 
and removes it from the wanted list. Because autosub thinks we have a dutch 
subtitle

If we wanted to implement this feature. 4 scenario are possible:
 - Check (with a complex structure) if a subtitle contains dutch language or english language
 - Add some header field to every subtitle file explaining if it is dutch or english
 - Save subtitle as Serie.Name.<lang>.srt If eng is download and there is no Serie.Name.nl.srt yet. Copy eng to Serie.Name.srt. If a nl subtitle is downloaded, copy it to Serie.Name.srt.
 - Have a database remember if we downloaded a dutch or a english subtitle

I am not going to implement option 1 and 2, simply because I think they are to 
complex. Option 3 is a possible solution except that I think it is a very bad 
way of programming, it goes against the design of AutoSub. So to implement this 
feature we need a database and a database is on the roadmap for release 0.6. 
This means this feature will not be included for the upcoming release.

I hope I have explained it clearly enough. 

But, I see another solution. Because of the flexibility of ExamplePostProcess. 
It is possible that you program this yourself.

Original comment by romke.va...@gmail.com on 20 Feb 2012 at 8:24

GoogleCodeExporter commented 9 years ago
>Now lets say, there is no dutch subtitle available for Show.Name.S01E01. 
AutoSub 
>download in your scenario a english subtitle as Show.Name.S01E01.srt. When 
autosub 
>runs a new scan it sees that Show.Name.S01E01.avi has a subtitle and removes 
it from 
>the wanted list. Because autosub thinks we have a dutch subtitle

Actually this is why I set subeng=en and subnl=nl, so scanDisk.py wouldn't do a 
check on availibility of Show.Name.S01E01.srt but on Show.Name.S01E01.nl.srt 
and *.en.srt, making my piece of (bad ;) code work (well, I think I tested all 
scenarios anyway)

But thanks for the tip on the postprocess, didn't think of that. It should be 
just as easy to add it in there instead.

Original comment by Simon.Ve...@gmail.com on 20 Feb 2012 at 8:55

GoogleCodeExporter commented 9 years ago
I won't fix this issue because there might come a complete redesign.

The current version of AutoSub will not support this, because it is only 
designed for dutch subtitles. 

Original comment by romke.va...@gmail.com on 23 Mar 2012 at 1:11

GoogleCodeExporter commented 9 years ago
Issue 100 has been merged into this issue.

Original comment by romke.va...@gmail.com on 18 May 2012 at 12:00

GoogleCodeExporter commented 9 years ago
I am not knowledgeable on the exact nature of this issue, but allow me to 
contribute an attempt at creativitity.

What about any of these ideas?
* make symbolic links for eiher *.en.srt/*.nl.srt to *.srt (as specified by 
user preference). Symbolic links can be traced to their original file and 
re-created to other files. Modern file systems support symbolic links 
(including Microsoft's NTFS), but I will concede the dependence on this feature 
may be undesirable.
* compare hash codes or file sizes of the existing subtitle files and the files 
that could be downloaded, if available. It is highly unlikely that the English 
and Dutch version would have identical values.

Original comment by wrc.drij...@gmail.com on 5 Apr 2013 at 3:45

GoogleCodeExporter commented 9 years ago
Issue 180 has been merged into this issue.

Original comment by romke.va...@gmail.com on 16 Apr 2013 at 8:26