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

One operation for renaming and file move & fixe for episodes without seasons #83

Closed
wants to merge 3 commits into from

Conversation

averissimo
Copy link

This will fix two bugs that were affecting me.

1. Fallback to season 0 for episodes without a defined season

For anime episodes that don't have a registered season it was returning a bug instead of falling back to no episode at all. This will fallback to season 0

2. One step for renaming and moving

If the configuration was set to rename and move files this would be done in a two step operation, first rename on the file's original directory and then move to the new path

This poses a problem when leaving symlinks behind as it would leave two symlinks in the original directory and a another symlink in the destination path (if run twice)

Example:
/original/path/Naruto Shippuuden - 323 [1080p].mkv

First run would result on (with always_move, leave_symlink and always_rename = true):
(symlink) /original/path/Naruto Shippuuden - 323 [1080p].mkv
(symlink) /original/path/Naruto Shippuuden - 323 - The Five Kage Assemble [1080p].mkv
(file) /new/path/Naruto Shippuuden - 323 [1080p].mkv

Second run would also create the following symlink:
(symlink) /new/path/Naruto Shippuuden - 323 - The Five Kage Assemble [1080p].mkv

ps. I wasn't able to separate these two pull requests after looking up documentation. If someone could show me how I can separate these

@lahwaacz
Copy link
Contributor

  1. That is a wrong place to do this, it should be done here. But I've not tested if it makes sense in the first place. Could you provide some filename to test it?
  2. I think this has been solved in fb2f54a, see also the following note.

Do you know that your code is based on old revision of tvnamer? Your branch has separated 5 months ago and is now about 30 commits behind. See https://github.com/dbr/tvnamer/network for details.

@averissimo
Copy link
Author

  1. The idea is for episodes that don't return a season number. I'll try and change there.

An example would be a anime episode that does not return a season number from tvdb.

example: [GroupA] Naruto Shippuuden - 320 [1080p].mkv

It is relevant for when the files are moved to a directory that depends on seasonnumber. Though the best solution would to fallback to a default string - such as "unspecified" - when it would happen, with seasonnumber or any other field.

  1. I didn't check ver3, i'll try it out thanks.

Thanks for the comments and for leading me in the right direction

@averissimo averissimo closed this Sep 13, 2013
@averissimo
Copy link
Author

  1. Following your suggestion I store the seasonnumber default value. check: averissimo@2ec012f
  2. Solved as you said in ver3 :)

@lahwaacz
Copy link
Contributor

  1. Maybe I just misunderstood, I thought that it's necessary before querying the database. Now I think it's only for formatting the final filename, right?

Anyway, if you want to implement the general fallback, it can be accomplished using collections.defaultdict or by redefining __getitem__() method in a subclass of dict:

class EPData(dict):
    def __init__(self, data):
        self.data = data

    def __getitem__(self, key):
        if key in self.data:
            return self.data[key]
        else:
            return "<unspecified>"

d = EPData({"h": "hello"})
print("%(h)s %(foo)s" % d)

Until #70 gets merged (relevant commit: lahwaacz/tvnamer@affde31), the implementation will not be very nice - every getepdata() method would have to be changed to return instance of either collections.defaultdict or EPData.
EDIT: of course, it is merged in ver3 branch... so it is enough to change it in just one place, best here

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.

2 participants