L4cache / kemono-dl

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

kemono-dl

A downloader tool for kemono.party and coomer.party.

How to use

  1. Install python 3. (Disable path length limit during install)
  2. Download source code for the latest release and extract it
  3. Then install requirements with pip install -r requirements.txt
    • If the command doesn't run try adding python -m, python3 -m, or py -m to the front
  4. Get a cookie.txt file from kemono.party/coomer.party
    • You can get a cookie text file on Chrome or Firefox with this extension.
    • A cookie.txt file is required to use favorites.
  5. Run python kemono-dl.py --cookies "cookie.txt" --links https://kemono.party/SERVICE/user/USERID
    • If the script doesn't run try replacing python with python3 or py

Command Line Options

To use login required features

--cookies FILE
Takes in a cookie file or a list of cookie files separated by a comma. Used to get around the DDOS protection(?). Your cookie file must have been gotten while logged in to use the favorite options.

What posts to download

--links LINKS
Takes in a url or list of urls separated by a comma.
--from-file FILE
Reads in a file with urls separated by new lines. Lines starting with # will not be read in.
--kemono-fav-users SERVICE
Downloads favorite users from kemono.party/su of specified type or types separated by a comma. Types include: all, patreon, fanbox, gumroad, subscribestar, dlsite, fantia. Your cookie file must have been gotten while logged in to work.
--coomer-fav-users SERVICE
Downloads favorite users from coomer.party/su of specified type or types separated by a comma. Types include: all, onlyfans. Your cookie file must have been gotten while logged in to work.
--kemono-fav-posts
Downloads favorite posts from kemono.party/su. Your cookie file must have been gotten while logged in to work.
--coomer-fav-posts
Downloads favorite posts from coomer.party/su. Your cookie file must have been gotten while logged in to work.

What files to download

--inline
Download the inline images from the post content.
--content
Write the post content to a html file. The html file includes comments if --comments is passed.
--comments
Write the post comments to a html file.
--json
Write the post json to a file.
--extract-links
Write extracted links from post content to a text file.
--dms
Write user dms to a html file. Only works when a user url is passed.
--icon
Download the users profile icon. Only works when a user url is passed.
--banner
Download the users profile banner. Only works when a user url is passed.
--announcements
Download announcements (always overwrite). Only works when a user url is passed. --yt-dlp (UNDER CONSTRUCTION)
Try to download the post embed with yt-dlp.
--skip-attachments
Do not download post attachments.
--overwrite
Overwrite any previously created files.

Output

--dirname-pattern PATTERN
Set the file path pattern for where files are downloaded. See Output Patterns for more detail.
--filename-pattern PATTERN
Set the file name pattern for attachments. See Output Patterns for more detail.
--inline-filename-pattern PATTERN
Set the file name pattern for inline images. See Output Patterns for more detail.
--other-filename-pattern PATTERN
Set the file name pattern for post content, extracted links, and json. See Output Patterns for more detail.
--user-filename-pattern PATTERN
Set the file name pattern for icon, banner, and dms. See Output Patterns for more detail.
--date-strf-pattern PATTERN
Set the date strf pattern variable. See Output Patterns for more detail.
--restrict-names
Set all file and folder names to be limited to only the ascii character set.

Download Filters

--archive FILE
Only download posts that are not recorded in the archive file.
--date YYYYMMDD
Only download posts published from this date.
--datebefore YYYYMMDD
Only download posts published before this date.
--dateafter YYYYMMDD
Only download posts published after this date.
--user-updated-datebefore YYYYMMDD
Only download user posts if the user was updated before this date.
--user-updated-dateafter YYYYMMDD
Only download user posts if the user was updated after this date.
--min-filesize SIZE
Only download attachments or inline images with greater than this file size. (ex #gb | #mb | #kb | #b)
--max-filesize SIZE
Only download attachments or inline images with less than this file size. (ex #gb | #mb | #kb | #b)
--only-filetypes EXT
Only download attachments or inline images with the given file type(s). Takes a file extensions or list of file extensions separated by a comma. (ex mp4,jpg,gif,zip)
--skip-filetypes EXT
Only download attachments or inline images without the given file type(s). Takes a file extensions or list of file extensions separated by a comma. (ex mp4,jpg,gif,zip)

Other

--help
Prints all available options and exit.
--version
Print the version and exit.
--verbose
Display debug information and copies output to a file.
--quite
Suppress printing except for warnings, errors, and exceptions.
--simulate
Simulate the given command and do not write to disk.
--no-part-files
Do not save attachments or inline images as .part files while downloading. Files partially downloaded will not be resumed if program stops.
--yt-dlp-args ARGS (UNDER CONSTRUCTION)
The args yt-dlp will use to download with. Formatted as a python dictionary object.
--post-timeout SEC
The time in seconds to wait between downloading posts. (default: 0)
--retry COUNT
The amount of times to retry / resume downloading a file. (default: 5)
--ratelimit-sleep SEC
The time in seconds to wait after being ratelimited (default: 120)
--ratelimit-ms MS The time in millisecond to limit before next request (default: 300)

--proxy-agent https://agent/proxy Proxy agent URL. This is NOT standrad http/s proxy. Pass 'u' parameter to agent for proxying. Not enabled by default. Enable this you can not download kemono and commer at once.

Options added in this fork

--[no-]local-hash
Hash check before skip existing files. (default: False)
--[no-]dupe-check
Look for same index file with similar name and compare to server hash to prevent duplicate downloads. Works only for naming schemes starts with index, for now (maybe). (default: True)

notice: idk if two args above works together or not, i'll probably never use options other than these two defaults because that's why i make them default. if you use them and have issues please report.

--dupe-check-pattern
Specify two patterns used by dupe-check, one for search inside folder, one for search in parent folder, separated by comma. Please include wildcard. (default: "{index}*,*{id}*/{index}*")
Default is to look for files with same index within same folder and "neighbor" folder with same post id (useful when using default file/folder name pattern).
--[no-]force-unlisted
Still try to request api if user is not found in creators list. Use carefully. (default: False)
--retry-403 COUNT
When get 403 (possibly because of DDoS-Guard), retry without session up to COUNT times. This mitigation is probably long-outdated as the situation seems self-solved. (default: 0)
--[mo-]fp-added
Filter posts by added date instead of published date. Override behavior of --date --dateafter --datebefore. (default: False)

Notes

Output Patterns

Variables

The pattern options allow you to modify the file path and file name using variables from the post. --dirname-pattern is the base file path for all post files. All file name patterns are appended to the end of the --dirname-pattern. File name patterns may also contain sub folder paths specific to that type of file such as with the default pattern for --inline-filename-pattern.

All variables referring to dates are controlled by --date-strf-pattern. Standard python datetime strftime() format codes can be found here.

All Options

Only file names

Default Patterns

--dirname-pattern

"Downloads\{service}\{username} [{user_id}]"  

--filename-pattern

"[{published}] [{id}] {title}\{index}_{filename}.{ext}"  

--inline-filename-pattern

"[{published}] [{id}] {title}\inline\{index}_{filename}.{ext}"  

--other-filename-pattern

"[{published}] [{id}] {title}\[{id}]_{filename}.{ext}"  

--user-filename-pattern

"[{user_id}]_{filename}.{ext}"  

--date-strf-pattern

"%Y%m%d"  

Examples

TODO