Sept. 15, 2022
This command-line tool automates the downloading of media (pictures and videos) from 9gag posts or comments in a variety of ways.
If you use and like this tool, consider passing a small token of appreciation by going to the release page, and making a small donation to the website.
There are two bundles - one each for Linux and Windows.
The bundle contains these files:
config.txt
file having most of the values pre-configured.root_folder
path (and a token
etc. as needed).For Linux, get 9gdownload.tar.gz.
And then, untar the archive using tar -xvzf 9gdownload.tar.gz
.
For Windows, get 9gdownload.zip.
Note: Your browser may mark it as a suspicious download (as there is an exe
in the archive), and may not show it in your Downloads folder. Just tell your browser to keep/download the archive. Then, extract the files.
The tool itself has been released under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License which, in summary, means non-commercial adaptation and/or redistribution of the tool is allowed with attribution (to https://randompearls.com/reference/tools/9gag-media-downloader).
Click on the links in this section for reading more about the license.
There are different ways in which the media can be downloaded, e.g. from all the comments on a post, for all the posts posted by a user etc.
The tool runs on command line and has been tested on Windows and Linux.9gdownload
9gdownload -c <path_of_config.txt>
The only (optional) argument the tool needs is -c
which tells the tool the location of the config file. This config file is otherwise expected to be located in the same folder where the tool resides (with the name config.txt
).
All the options present in the config file are explained below.
There are three types of configuration values. You can modify them in the config file.
Option and Type | Description |
---|---|
token (str) |
The key determining a post, interest, tag or a user. Can be obtained from the URL as shown below: Not used (needed) with the |
gag_type (str) |
Where to get the media from.POST_COMMENTS : from comments on a given postUSER_POSTS : from posts posted by a given userUSER_LIKES : from posts liked by a given userUSER_COMMENTS : from posts commented on by a given userUSER_SAVED : from posts saved by the user (this needs authorization, see PHPSESSID and session )TAG INTEREST DEFAULT : from 9gag home page |
gag_subtype (str) |
Further specifies the type of page to get media from. Works in conjunction with gag_type .- HOT (goes with only TAG and INTEREST )- FRESH (for TAG , INTEREST and DEFAULT )- HOME goes with only DEFAULT - TOP goes with only DEFAULT - TRENDING goes with only DEFAULT |
PHPSESSID (str) and session (str) |
Needed only for the USER_SAVED gag_type .To get these values, open your saved posts in a browser and then go to Developer tools -> Network, and filter for requests having saved? - will have to scroll a bit. Then from its Cookies, copy these two values. |
Option and Type | Description |
---|---|
root_folder (str) |
Must exist. This is where a folder will be created for saving media. |
removed_folder_suffix (str) |
Good for multiple runs. If you create a folder with the media folder name and this suffix, files that you move to this folder manually will not be re-downloaded. Helps in keeping the media folder clean. |
should_save (bool) |
If False , media urls will only be shown, but not saved |
get_image_only (bool) |
If True, videos will not be downloaded |
get_image_with_video (bool) |
If True, get images as well for videos, ineffective with get_image_only=True |
max_save_workers (int) |
There is only one find worker thread (for media URLs discovery), but for saving we can have multiple as specified by this option |
pause_find (bool) |
Should or not pause (for a keypress) after every run of url discovery, True is recommended |
overwrite (bool) |
Overwrite or not the existing files in subsequent runs |
sleeptime (float) |
Time between saves. Do not make it zero or it may trigger DoS attack on the server. |
Option and Type | Description |
---|---|
headers (dict) |
The headers sent with the requests. |
appId (str) |
|
auth_key (str) |
Not needed currently |
Any comments, bug-reports and feedback are heartily welcome!