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

[kemono] Add the additional field type: attachment, file (a, f) #1556

Closed
TestPolygon opened this issue May 14, 2021 · 8 comments
Closed

[kemono] Add the additional field type: attachment, file (a, f) #1556

TestPolygon opened this issue May 14, 2021 · 8 comments

Comments

@TestPolygon
Copy link

TestPolygon commented May 14, 2021

I have already posted about this problem here: #1514 (comment)

The resume

Currently the program has the unsafe behavior from the box.

For example:

https://data.kemono.party/files/fanbox/{user}/{id}/Untitled.jpe            downloaded (200 KB preview)
https://data.kemono.party/attachments/fanbox/{user}/{id}/Untitled.jpe      NOT downloaded (2 MB file)
https://data.kemono.party/attachments/fanbox/{user}/{id}/Untitled_1.jpe    downloaded (2 MB file)
https://data.kemono.party/attachments/fanbox/{user}/{id}/Untitled_2.jpe    downloaded (2 MB file)

Also the problem happens with using --download-archive option. Even you use {num} as workaround for the example above.
#1514 (comment)

The decision

Add the additional field type which can be attachment or file.


I think it makes sense to add the additional field type: attachment, file.
And short aliases (type-alias): a and f to use them in filename.

For example:
"{id}_{title}_{type-alias}_{filename}.{extension}"
or
"{id}_{title}_{filename}_{type-alias}.{extension}"


And the same change should be done with --download-archive. The DB entries shoud be now look so:
"{type-alias}_{the_current_row_format}".

So, if the entry has no type-alias prefix (it's the row that was created before this supposed update) it shoud be consided that it is a preview f (file), since they are placed before the original file with type a (attachment).

With this change people that used --download-archive can just easily download only the missing files. No need to redownload all files.

@TestPolygon TestPolygon changed the title [kemono] Add the additional field type: attachment, file (a, f) [kemono] Add the additional field type: attachment, file (a, f) May 14, 2021
mikf added a commit that referenced this issue May 15, 2021
'file', 'attachment', or 'inline'
@TestPolygon
Copy link
Author

TestPolygon commented May 15, 2021

Technically there is also the type embed (e), but I did see no one such file yet.

Based on API response a post can contain 1 file, 1 embed, and multiple attachments.

"attachments": [],
"embed": {},
"file": {},

And technically a file, an embed and one of attachments can have the same filename.


Please, add also type-alias — the short form of type. (f, a, e) There is no sense to add to the filename so much characters instead of just one to define a file type.

Or is there a way to do it manually? In fact it's just substring(0, 1).


UPD. There are inline (i) files in Patreon's posts also. It is already implemented here. Just a note.


UPD 2. Embed it an embed link (not a file) in Patreon's post:

"embed": {
    "description": "Watch this GIF by ... on Gfycat. Discover more GIFS online at Gfycat.",
    "subject": "Create, Discover and Share GIFs on Gfycat",
    "url": "https://gfycat.com/..."
},

@mikf
Copy link
Owner

mikf commented May 17, 2021

Or is there a way to do it manually? In fact it's just substring(0, 1).

{type[0]} will return the first letter of type

@Skyofflad
Copy link

Skyofflad commented May 26, 2021

For me it doesn't work
{type} returns as None in the filename (as well as {type[0]})

@mikf
Copy link
Owner

mikf commented May 26, 2021

@Skyofflad You need the pre-release/dev snapshot for this.
Executables can be found here, instructions for pip are here.

@Skyofflad
Copy link

@Skyofflad You need the pre-release/dev snapshot for this.
Executables can be found here, instructions for pip are here.

I'm already using the latest executable.
Here is the output of -K option:

Keywords for filenames and --filter:
------------------------------------
added
  Sat, 01 May 2021 12:51:21 GMT
attachments[][name]
  dens_2.png
attachments[][path]
  /attachments/797556/50700943/dens_2.png
attachments[][type]
  attachment
category
  kemonoparty
content
  
date
  2021-05-01 01:49:17
edited
  Sat, 01 May 2021 01:49:17 GMT
extension
  png
file[name]
  dens 2.png
file[path]
  /files/797556/50700943/dens_2.png
file[type]
  file
filename
  dens 2
id
  50700943
num
  1
published
  Sat, 01 May 2021 01:49:17 GMT
service
  patreon
shared_file
  False
subcategory
  post
title
  Densatra
user
  797556
username
  Skygracer

There is no type field. {file[type]} always returns file. {type} and {attachments[type]} return None
Also, inline images don't even have these fields.

@TestPolygon
Copy link
Author

Yeah, there is no such property in 1.17.5-dev.

@mikf
Copy link
Owner

mikf commented May 28, 2021

Turns out I'm incredibly dumb and managed to add the type field to the wrong dict in 2b5d808 and didn't notice because I didn't include a test ... anyway, fixed in c0fa505

@TestPolygon
Copy link
Author

TestPolygon commented May 31, 2021

It works fine for me with:

"archive-format": "{service}_{user}_{type[0]}_{id}_{filename}.{extension}",

(Do not forget to add using of {type[0]} in "filename")


As I said earlier, the current default archive_fmt is not proper.

archive_fmt = "{service}_{user}_{id}_{filename}.{extension}"

Since an attachment and a file with the same name within one post are considered as the same file while it can be not true.


The same thing is with filename:

filename_fmt = "{id}_{title}_{filename}.{extension}"

It requires to add {type[0]}/{type}, or {num}/{num:>02}.

@mikf mikf closed this as completed Jun 19, 2021
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

No branches or pull requests

3 participants