L4cache / kemono-dl

(personal fork of) A simple kemono.party downloader using python.
97 stars 15 forks source link

[Bug] ValueError("{!r} is not in the subpath of {!r}" #27

Closed tezrilet closed 7 months ago

tezrilet commented 1 year ago

Version

Version: 2022.04.28 (https://github.com/L4cache/kemono-dl/commit/1fffd9701d9b814307ce049e7a968cce6a6b432a)

Your Command

python3 /root/kemono-dl/kemono-dl.py --cookies /root/kemono-dl/cookies-kemono-party.txt --inline --content --comments --json --dms --dirname-pattern \"{username}\\{service}\" --filename-pattern \"[{id}] ({published}) {title}\\{filename}.{ext}\" --inline-filename-pattern \"[{id}] ({published}) {title}\inline\{filename}.{ext}\" --other-filename-pattern \"[{id}] ({published}) {title}\other\{filename}.{ext}\" --date-strf-pattern \"%Y-%m-%d\" --from-file download.txt --archive archive.txt

The download.txt contains URLs of posts, 1 per line.

Description of bug

Fails to download a post.

How To Reproduce

Run the above command. It will only fail to download certain posts, but I'm not sure what triggers the error.

Error messages and tracebacks

INFO:Downloading posts from kemono.su | <ommitted> | <ommitted> | <ommitted>
DEBUG:Requesting post json from: https://kemono.su/api/v1/<ommitted>/user/<ommitted>/post/<ommitted>
ERROR:Unable to get posts for https://kemono.su/<ommitted>/user/<ommitted>/post/<ommitted>
Traceback (most recent call last):
  File "/root/kemono-dl/src/main.py", line 834, in start_download
    self.get_post(url)
  File "/root/kemono-dl/src/main.py", line 200, in get_post
    post = self.clean_post(post, user, site)
  File "/root/kemono-dl/src/main.py", line 391, in clean_post
    content_soup = self.get_inline_images(new_post, content_soup)
  File "/root/kemono-dl/src/main.py", line 310, in get_inline_images
    inline_image['src'] = str(pathlib.Path(file['file_path']).relative_to(html_loc))
  File "/usr/lib/python3.10/pathlib.py", line 818, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: '<ommitted>.jpg' is not in the subpath of '<ommitted>/other' OR one path is relative and the other is absolute.

Additional comments

I can provide specific URLs and full debug logs privately. Is there any way I can send them?

L4cache commented 1 year ago

Try change the other-filename-pattern or inline-filename-pattern to make inline files go to a sub folder of other files (html files in this case.) For example, remove "other/" from other-filename-pattern or add "other/" before "inline/" to inline-filename-pattern.

tezrilet commented 1 year ago

Thank you! That works now. I have a question if you don't mind. With this fix, is it not possible to keep other files and inline files separate in their own folders, and not in a subfolder? This is how I had it before and it was working fine.

L4cache commented 1 year ago

Thank you! That works now. I have a question if you don't mind. With this fix, is it not possible to keep other files and inline files separate in their own folders, and not in a subfolder? This is how I had it before and it was working fine.

I can try that