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

Downloading tags as separate files (for Hydrus) #135

Closed
DonaldTsang opened this issue Dec 8, 2018 · 10 comments
Closed

Downloading tags as separate files (for Hydrus) #135

DonaldTsang opened this issue Dec 8, 2018 · 10 comments

Comments

@DonaldTsang
Copy link

DonaldTsang commented Dec 8, 2018

Is it possible to name the gallery file by md5 while putting the tags in a separate txt file with the same md5 hash? Bonus points if that is a default flag in gallery-dl.
that will be used for importing in https://github.com/hydrusnetwork/hydrus

@mikf
Copy link
Owner

mikf commented Jan 7, 2019

Filenames can be specified by setting a custom filename format (e.g. "{md5}.{extension}").

With 38500ad it is now possible to write all file-metadata to a separate .json file, although that would currently be all metadata, not just tags. I really don't know what exactly is needed to make it Hydrus-compatible, so please tell me.

Also: an example config snippet for danbooru that enables this would look something like the following:

"danbooru": {
    "filename": "{md5}.{extension}",
    "postprocessors": [{"name": "metadata"}]
}

@DonaldTsang
Copy link
Author

DonaldTsang commented Jan 8, 2019

Cross referencing: Bionus/imgbrd-grabber#1492
(with further reference in Bionus/imgbrd-grabber#1001 and Bionus/imgbrd-grabber#588 and Bionus/imgbrd-grabber#573)

It is best to make it one tag per newline, and one txt file per image (\n)

@rachmadaniHaryono
Copy link
Contributor

alternative to this is using server framework like in #146. it just need a function to convert gallery-dl metadata to hydrus compatible metadata

@DonaldTsang
Copy link
Author

DonaldTsang commented Jan 8, 2019

@rachmadaniHaryono could you explain this further? Since Hydrus's API hasn't been released yet

@rachmadaniHaryono
Copy link
Contributor

basically create a api server, which will return json data from url input. this will make gallery-dl act as parser for hydrus.

@mikf
Copy link
Owner

mikf commented Jan 19, 2019

I've added a mode option to the metadata post processor to tell it how and what kind of metadata it should write. To get a separate .txt file with tags, you should use "mode": "tags":

"danbooru": {
    "filename": "{md5}.{extension}",
    "postprocessors": [{
        "name": "metadata",
        "mode": "tags"
    }]
}

This will create a {md5}.jpg.txt file for each image, filled with one tag per line.

@mikf mikf closed this as completed Jan 22, 2019
@DonaldTsang
Copy link
Author

DonaldTsang commented Jan 23, 2019

@mikf thanks for the option, is it possible to add a command flag for that (maybe -hydrus or -text-tag)?

@mikf
Copy link
Owner

mikf commented Jan 26, 2019

@DonaldTsang --write-tags

@DonaldTsang
Copy link
Author

@mikf thanks, what about in a python library import (import gallery-dl)?

@mikf
Copy link
Owner

mikf commented Jan 27, 2019

You need to somehow attach a MetadataPP object to your job's post processors.

One way is to use the config module to set an appropriate postprocessors option before constructing a job object:

from gallery_dl import config, job

config.set(("postprocessors",), [{
    "name": "metadata",
    "mode": "tags",
}])

j = job.DownloadJob("URL")
j.run()

Or you can construct one yourself before calling job.run():

from gallery_dl import job
from gallery_dl.postprocessor import metadata

m = metadata.MetadataPP(None, {"mode": "tags"})

j = job.DownloadJob("URL")
j.postprocessors = [m]
j.run()

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

3 participants