AlphaSlayer1964 / kemono-dl

A simple kemono.party downloader using python.
509 stars 82 forks source link

Weird error saying the directory dosent exist since the file name is too long #55

Closed xXTG2Xx closed 2 years ago

xXTG2Xx commented 2 years ago

Version

Version: 2022.02.09

Your Command


python kemono-dl.py --cookies "cookies.txt" --links https://kemono.party/patreon/user/36165675 --yt-dlp --extract-links --ignore-errors

Description of bug

From what i understand the code has some file naming error since it tried to name a directory a name which is way too long for windows to handle(in debug.log) and after when the code tried to access the directory it didnt exist since windows couldn't create it and thats whats caused the error

How To Reproduce

Just use the command I typed( " python kemono-dl.py --cookies "cookies.txt" --links https://kemono.party/patreon/user/36165675 --yt-dlp --extract-links --ignore-errors " )

Error messages and tracebacks


INFO: Downloading Post: [animation meme] bby my phone
DEBUG: user_id: 36165675 service: patreon post_id: 60699716 url: https://kemono.party/patreon/user/36165675/post/60699716
DEBUG: Sleeping for 0 seconds
DEBUG: Preparing download: File Name: [1]_https___www.patreon.com_media-u_Z0FBQUFBQmg4MVdtTDN6WkNhOUxWWnRYdnlXVVpIcmhDRXl2UU53REUxZTRPbXpuaFNoQzNVY19rdUFjcWd3dVBoV2JJYkl5WkVZNUxySHhRMVpaN2luclJ5OEEtaDJSdWY2SnpGN3Nyd20zSnFfeU9vVzQ4eURaYndvZ2IydlFlNmRzU1dPMXF4eXRVc0VqeHlVQWNNNEtwcG9wS0syQm1RPT0 URL: https://kemono.party/data/d0/c5/d0c555a68fe8286183e6b51aec591f85538c90a7b9352e21aeb889fd0f21d662.jpg?f=https://www.patreon.com/media-u/Z0FBQUFBQmg4MVdtTDN6WkNhOUxWWnRYdnlXVVpIcmhDRXl2UU53REUxZTRPbXpuaFNoQzNVY19rdUFjcWd3dVBoV2JJYkl5WkVZNUxySHhRMVpaN2luclJ5OEEtaDJSdWY2SnpGN3Nyd20zSnFfeU9vVzQ4eURaYndvZ2IydlFlNmRzU1dPMXF4eXRVc0VqeHlVQWNNNEtwcG9wS0syQm1RPT0=
INFO: Downloading [1]_https___www.patreon.com_media-u_Z0FBQUFBQmg4MVdtTDN6WkNhOUxWWnRYdnlXVVpIcmhDRXl2UU53REUxZTRPbXpuaFNoQzNVY19rdUFjcWd3dVBoV2JJYkl5WkVZNUxySHhRMVpaN2luclJ5OEEtaDJSdWY2SnpGN3Nyd20zSnFfeU9vVzQ4eURaYndvZ2IydlFlNmRzU1dPMXF4eXRVc0VqeHlVQWNNNEtwcG9wS0syQm1RPT0
Traceback (most recent call last):
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 748, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 176, in _find_posts
    self.download_post()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 188, in download_post
    self._download_attachments()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 317, in _download_attachments
    self._requests_download(file_url, file_name, file_hash)
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 555, in _requests_download
    with open(file_name, 'ab') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Kemono.party dl\\kemono-dl-2022.02.09\\Downloads\\patreon\\typh [36165675]\\[20220104] [60699716] [animation meme] bby my phone\\[1]_https___www.patreon.com_media-u_Z0FBQUFBQmg4MVdtTDN6WkNhOUxWWnRYdnlXVVpIcmhDRXl2UU53REUxZTRPbXpuaFNoQzNVY19rdUFjcWd3dVBoV2JJYkl5WkVZNUxySHhRMVpaN2luclJ5OEEtaDJSdWY2SnpGN3Nyd20zSnFfeU9vVzQ4eURaYndvZ2IydlFlNmRzU1dPMXF4eXRVc0VqeHlVQWNNNEtwcG9wS0syQm1RPT0'

Additional comments

It downloaded the first posts normally but failed to download that specific one can't be sure for the other posts since --ignore-errors isnt a thing anymore

AlphaSlayer1964 commented 2 years ago

When you installed python did you disable path length limit? I just tried that post and the file downloaded successfully. Also it's very annoying kemono party has not fixed the broken file names where the file name is a url!

xXTG2Xx commented 2 years ago

Ok so that fixed the file name one i think but its giving me this error now even before downloading a single post i even ran it as admin and it didnt work

INFO: Downloading Post: [finished art dump] hazel vibin + sketchy bust commissions pt.4
Traceback (most recent call last):
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 176, in _find_posts
    self.download_post()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 187, in download_post
    self._download_content()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 333, in _download_content
    os.makedirs(self.current_post_path)
  File "D:\AppData\Local\Programs\Python\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "D:\AppData\Local\Programs\Python\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "D:\AppData\Local\Programs\Python\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "D:\AppData\Local\Programs\Python\Python310\lib\os.py", line 225, in makedirs
    mkdir(name, mode)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'D:\\Kemono.party dl\\kemono-dl-2022.02.10\\Downloads'

Edit: I used the same command as mentioned above and i reinstalled python with the path limit thing i updated my cookies.txt and i also tried to create the downloads folder it still cant find it also i got this error

INFO: Downloading Post: [finished art dump] hazel vibin + sketchy bust commissions pt.4
Traceback (most recent call last):
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 748, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 176, in _find_posts
    self.download_post()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 187, in download_post
    self._download_content()
  File "D:\Kemono.party dl\kemono-dl-2022.02.09\src\main.py", line 331, in _download_content
    with open(os.path.join(self.current_post_path, 'content.html'),'wb') as f:
OSError: [Errno 9] Bad file descriptor

D:\Kemono.party dl\kemono-dl-2022.02.10>python kemono-dl.py --cookies "cookies.txt" --links https://kemono.party/patreon/user/36165675 --yt-dlp --extract-links --ignore-errors
Traceback (most recent call last):
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 1, in <module>
    from src.main import main
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 20, in <module>
    from .logger import logger
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\logger.py", line 26, in <module>
    file_handler = logging.FileHandler('debug.log', encoding="utf-16")
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1169, in __init__
    StreamHandler.__init__(self, self._open())
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1201, in _open
    return open_func(self.baseFilename, self.mode,
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Kemono.party dl\\kemono-dl-2022.02.10\\debug.log'

the above(debug.log) one was fixed after i copied over the debug.log from my old debug run(v.2022.02.9)

AlphaSlayer1964 commented 2 years ago

Looking at the last error you get at least it seems like your python install is borked or something. The last error with the debug.log is an error with pythons built in logger. When I test with your command with a fresh download from the releases for 2022.02.10 it works fine. Can you post your debug.log file.

xXTG2Xx commented 2 years ago

yeah so um i tried putting --verbose at the end and its said that debug.log didn't exist so i created it myself and this is what i got in the console and there is nothing in the debug.log file

--- Logging error ---
Traceback (most recent call last):
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1104, in emit
    self.flush()
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1084, in flush
    self.stream.flush()
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 757, in main
    logger.debug(f"Given command: python {' '.join(sys.argv)}")
Message: 'Given command: python kemono-dl.py --cookies cookies.txt --links https://kemono.party/patreon/user/36165675 --verbose'
Arguments: ()
DEBUG: Given command: python kemono-dl.py --cookies cookies.txt --links https://kemono.party/patreon/user/36165675 --verbose
--- Logging error ---
Traceback (most recent call last):
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1104, in emit
    self.flush()
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1084, in flush
    self.stream.flush()
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 149, in _find_posts
    logger.info(f"Downloading User: {self.current_user['username']}")
Message: 'Downloading User: typh'
Arguments: ()
INFO: Downloading User: typh
--- Logging error ---
Traceback (most recent call last):
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1104, in emit
    self.flush()
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1084, in flush
    self.stream.flush()
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 150, in _find_posts
    logger.debug(f"user_id: {self.current_user['user_id']} service: {self.current_user['service']} url: https://{self.current_user['site']}.party/{self.current_user['service']}/user/{self.current_user['user_id']}")
Message: 'user_id: 36165675 service: patreon url: https://kemono.party/patreon/user/36165675'
Arguments: ()
DEBUG: user_id: 36165675 service: patreon url: https://kemono.party/patreon/user/36165675
--- Logging error ---
Traceback (most recent call last):
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1104, in emit
    self.flush()
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1084, in flush
    self.stream.flush()
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 160, in _find_posts
    logger.debug(f'User API URL: {api_url}')
Message: 'User API URL: https://kemono.party/api/patreon/user/36165675?o=0'
Arguments: ()
DEBUG: User API URL: https://kemono.party/api/patreon/user/36165675?o=0
--- Logging error ---
Traceback (most recent call last):
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1104, in emit
    self.flush()
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1084, in flush
    self.stream.flush()
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 176, in _find_posts
    self.download_post()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 183, in download_post
    logger.info(f"Downloading Post: {clean_folder_name(self.current_post['title'])}")
Message: 'Downloading Post: [finished art dump] hazel vibin + sketchy bust commissions pt.4'
Arguments: ()
INFO: Downloading Post: [finished art dump] hazel vibin + sketchy bust commissions pt.4
--- Logging error ---
Traceback (most recent call last):
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1104, in emit
    self.flush()
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1084, in flush
    self.stream.flush()
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 176, in _find_posts
    self.download_post()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 184, in download_post
    logger.debug("user_id: {user} service: {service} post_id: {id} url: https://{site}.party/{service}/user/{user}/post/{id}".format(site=self.current_user['site'],**self.current_post))
Message: 'user_id: 36165675 service: patreon post_id: 62143559 url: https://kemono.party/patreon/user/36165675/post/62143559'
Arguments: ()
DEBUG: user_id: 36165675 service: patreon post_id: 62143559 url: https://kemono.party/patreon/user/36165675/post/62143559
--- Logging error ---
Traceback (most recent call last):
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1104, in emit
    self.flush()
  File "D:\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1084, in flush
    self.stream.flush()
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 176, in _find_posts
    self.download_post()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 185, in download_post
    logger.debug(f"Sleeping for {args['post_timeout']} seconds")
Message: 'Sleeping for 0 seconds'
Arguments: ()
DEBUG: Sleeping for 0 seconds
Traceback (most recent call last):
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\kemono-dl.py", line 4, in <module>
    main()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 765, in main
    downloader(urls)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 68, in __init__
    self.add_links()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 120, in add_links
    self._parse_links(url)
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 128, in _parse_links
    self._find_posts(user.group(1),user.group(2),user.group(3))
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 176, in _find_posts
    self.download_post()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 187, in download_post
    self._download_content()
  File "D:\Kemono.party dl\kemono-dl-2022.02.10\src\main.py", line 337, in _download_content
    os.makedirs(self.current_post_path)
  File "D:\AppData\Local\Programs\Python\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "D:\AppData\Local\Programs\Python\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "D:\AppData\Local\Programs\Python\Python310\lib\os.py", line 225, in makedirs
    mkdir(name, mode)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'D:\\Kemono.party dl\\kemono-dl-2022.02.10\\Downloads\\patreon'
AlphaSlayer1964 commented 2 years ago

I would uninstall and reinstall python because I'm using the built in python logging module. It should automatically create the debug.log file if it doesn't exist. Also when it says it can't find the Downloads folder that shouldn't happen because it makes that folder if it's not there. It seems like your python doesn't have the proper permissions to create new files somehow. Why that is I have no idea unfortunately.

AlphaSlayer1964 commented 2 years ago

I assume the issue has been fixed.