Loading...
Random Pearls Random Pearls New Menu
  • All Pearls
    • Random Pearls
  • Tools
    • Tools  (parent page)
    • Reference  (parent page of Tools)
  • New Menu
  • Authors
  •  
  • Contact Us
  • Sign up
  • Login
    Forgot Password?
  • Follow us on
Image Back to Top Back to top
Language Preference
This website has language specific content. Here you can set the language(s) of your preference.

This setting does not affect the current page. It is used only for filtering pages in menus, preview tiles and search results.

It can be changed any time by using the login menu (if you are logged in) or by clicking the Language button on the left bottom of the page.
Log in to save your preference permanently.



If you do not set this preference, you may see a header like This page has 'language_name' content in page preview tiles.
Search
  • Navigation
  • Similar
  • Author
  • More...
You are here:
All Content / Reference / Tools / 9Gag Media Downloader
Table of Contents

Subscribe to Our Newsletter
Follow us by subscribing to our newsletter and navigate to the newly added content on this website directly from your inbox!
Login to subscribe to this page.
Categories  
Tags  
Author  
Eontra

Just happen to be here...


9Gag Media Downloader

Sept. 15, 2022

For collectors!


This command-line tool automates the downloading of media (pictures and videos) from 9gag posts or comments in a variety of ways.

Use Cases

  • There is a user who uploads really nice wallpapers as his posts, and you want to download those pictures from all of his posts.
  • For a given post, there are very good videos in its comments, and you want to get all of those videos.
  • A user makes it a point to comment on really interesting posts, and you want the media of all such posts.
  • So on...

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.

Couple of Points to Note
  • Rest assured, there is no virus in this tool, I've not (yet) released the source code simply because I do not want 9gag to change their API (even a small change will make the tool useless).
  • Also, there is no web-scraping being done - so this tool is very lightweight and fast in terms of the network bandwidth it uses.

Download

There are two bundles - one each for Linux and Windows.

The bundle contains these files:

  1. The binary or the .exe file.
  2. README.md
  3. LICENSE
  4. config.txt file having most of the values pre-configured.
    Remember to provide a 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.


License

Creative Commons License
By using this tool to save media from 9gag on your own device, you agree to not post this media in the form of memes or any other way elsewhere if the media is copyrighted.
The onus of determining copyright on the media and respecting it is on the user of the tool.

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. Creative Commons License


Usage

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.

Changed Often
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:
- Post key: https://9gag.com/gag/<postkey>
- username: https://9gag.com/u/<username>
- tag: https://9gag.com/tag/<tag>
- interest: https://9gag.com/interest/<interest>

Not used (needed) with the DEFAULT gag_type.

gag_type (str) Where to get the media from.
POST_COMMENTS: from comments on a given post
USER_POSTS: from posts posted by a given user
USER_LIKES: from posts liked by a given user
USER_COMMENTS: from posts commented on by a given user
USER_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.
Changed Sometimes
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.
Changed Rarely
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!

Advertisement

A Reason to Donate

The page has no or minimal advertisement. If you want to contribute towards keeping this website running, think about donating a small amount. This helps in reducing the number of ads as well. You can decide the amount on the payment page. Thanks!
Advertisement

Advertisement
Close ad Ad

Return to Tools

Tell us what you think (select text for formatting, or click )

Copyright © randompearls.com 2020

Privacy Policy