Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub extension fix #13

Closed

Conversation

lucacerone
Copy link
Contributor

Hi,
I noticed that if you call addic7ed somefile.avi, but the avi file is not in the directory,
then the subtitle is dowloade with the name of the file, rather than with the correct .srt extension.

E.g.:

addic7ed an_episode_name.avi

downloads the subtitle as "an_episode_name.avi" rather than as "an_episode_name.srt".

This commit fix this.

When the video file is not present in the directory
the subtitle was downloaded with the same name provided in input.
This commit redefines 'remove_extension' and fix this.
@JoelSjogren
Copy link
Contributor

Hi, about the '.part' line that you removed: #4. I need that feature to stay.

Benoit, what was the intention behind the isfile line?

@JoelSjogren
Copy link
Contributor

I think the new remove_extension behaves better. It is sound that the input and output be in the same directory. For example,

filename = "a.b/c"
>>> filename.rpartition('.')[0] if '.' in filename else filename
'a'
>>> import os
>>> os.path.splitext(filename)[0]
'a.b/c'

@BenoitZugmeyer
Copy link
Owner

I'm OK with this. Please support .part files in remove_extension, something like

def remove_extension(filename):
    filename, ext = os.path.splitext(filename)
    if ext == '.part':
        filename, ext = os.path.splitext(filename)
    return filename

Also, if you know git, please rebase this pull request into one or two clean commits (at least, no merge commit). Else I'll do it.

@lucacerone
Copy link
Contributor Author

Hi Benoit and Joel,
first of all thanks for looking at the pull request.

I started looking at your code because I wanted to create a similar program and have found your.
I am now hacking into it, mostly for learning purposes, and to add a couple of features I might need.

I didn't realized the .part is actually needed when you are downloading a file (I naively though the file would be called something like "the.file.part" rather than "the.file.mp4.part".
I'll fix that.

About git rebase, sorry I have never used it, but will look into how to use it to have a cleaner history.

Thanks again guys.

@@ -382,7 +376,10 @@ def normalize_release(release):


def remove_extension(filename):
return filename.rpartition('.')[0] if '.' in filename else filename
filename, ext = os.path.splitext(filename)
if ext in ['.part','.!qB']:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to manage also partial downloads using qBittorrent (and updating the list one can handle other softwares that append a suffix to the file while downloading).

Bugfix.

When the video file is not present in the directory
the subtitle was downloaded with the same name provided in input.
This commit redefines 'remove_extension' and fix this.
@lucacerone lucacerone closed this Jul 12, 2014
@lucacerone lucacerone deleted the sub_extension_fix branch July 12, 2014 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants