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

Feature: Custom naming #265

Open
Typhonragewind opened this issue May 31, 2023 · 3 comments
Open

Feature: Custom naming #265

Typhonragewind opened this issue May 31, 2023 · 3 comments

Comments

@Typhonragewind
Copy link
Contributor

Thanks for all the work on Dosage, it's amazing!

I was wondering if you have any plans or if it is even feasible to add custom naming - like instead of the filenames from the sites, one could define the files to have a custom numbering system.

This would probably mean parsing the entire site before downloading, since it starts from the latest comic strip though

@Typhonragewind
Copy link
Contributor Author

Typhonragewind commented May 31, 2023

I actually wrote a small script that can be used to achieve this (though not foolproof, as it depends on the creation time of the file)

import os

root = "/Webcomics"

for folder in os.listdir(root):
    f = os.path.join(root,folder)

    count = 1

    files = list(os.listdir(f))
    files.sort(key=lambda fn: os.path.getctime(os.path.join(f, fn)))
    files.reverse()
    
    for i in files:
        if i is not str(count).zfill(4):
            file_name, file_extension = os.path.splitext(os.path.join(f, i))
            os.rename(os.path.join(f, i), os.path.join(f, str(count).zfill(5) + file_extension))
            count = count + 1
        else:
            count = count + 1
            continue

@TobiX
Copy link
Member

TobiX commented May 31, 2023

There is something similar in the tools directory: https://github.com/webcomics/dosage/blob/master/scripts/create-cbz.py - Not sure if I want to entertain such a feature in the core of Dosage, but maybe as a power-user feature... This might be something which could be implemented as an EventHandler...

@Typhonragewind
Copy link
Contributor Author

I'm not familiar with how you handle things in Dosage, but maybe make this as something that cannot be used in the initial full download of a comic, only when there are already files present comic, or when used with the -c option, because otherwise it would be difficult to ascertain the number position of a single file (would have to traverse the whole site).

Additionally, the script i wrote may have issues if comics are downloaded using parallelization.

I tried looking into the EventHandlers, but i do not have code experience to fully grasp it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants