• This repository has been archived on 01/Nov/2022
  • Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⏬ Download ALL xkcd's which have been uploaded till date. Ever!
logo

PyPI version License Travis

Download each and every xkcd comic uploaded! Like ever!

Author:Tasdik Rahman

1   Features

  • Can download all the xkcd's uploaded till date(1603 as I am writing this!).
  • Download individual xkcd's and store them
  • Download ranges of xkcd's and store them
  • Download the latest issue xkcd
  • Download the meta text inside each xkcd and store it
  • No duplicacy in your XKCD database.
  • Stores each xkcd in a separate file named as the title of the xkcd at your home directory
  • Writes a description.txt for each xkcd. Storing meta-data like
    • date-publised
    • url value
    • a small description of that xkcd
    • The alt text on the comic
  • written in uncomplicated python.

2   Demo

Usage

Usage

Each Comic is stored in it's own individual folder with a description.txt placed in it. It contains meta-data like - img-link - title - date-published - alt

Here's a little example for the same

xkcd\_archive Structure

xkcd_archive Structure

3   Usage

When running for the first time, do a xkcd-dl --update-db

$ xkcd-dl --update-db
XKCD link database updated
Stored it in 'xkcd_dict.json'. You can start downloading your XKCD's!
Run 'xkcd-dl --help' for more options
$

3.1   --help

$ xkcd-dl --help
usage: xkcd-dl [-h] [-u] [-l] [-d XKCD_NUM | -a]
               [-r [DOWNLOAD_RANGE [DOWNLOAD_RANGE ...]]] [-v] [-P PATH]
               [-s XKCD_NUM]

Run `xkcd-dl --update-db` if running for the first time.

optional arguments:
  -h, --help            show this help message and exit
  -u, --update-db       Update the database
  -l, --download-latest
                        Download most recent comic
  -d XKCD_NUM, --download XKCD_NUM
                        Download specified comic by number
  -a, --download-all    Download all comics
  -r [DOWNLOAD_RANGE [DOWNLOAD_RANGE ...]], --download-range [DOWNLOAD_RANGE [DOWNLOAD_RANGE ...]]
                        Download specified range
  -v, --version         show program's version number and exit
  -P PATH, --path PATH  set path
  -s XKCD_NUM, --show XKCD_NUM
                        Show specified comic by number

3.2   --download-latest

This downloads the last uploaded xkcd comic and stores under the home directory of the user with a brief description

$ xkcd-dl --download-latest
Downloading xkcd from 'http://imgs.xkcd.com/comics/flashlights.png' and storing it under '/home/tasdik/xkcd_archive/1603'
$

If it has been downloaded, will not do anything

This command will work even if you have not run --update-db yet.

3.3   --download=XKCDNUMBER

Downloads the particular XKCDNUMBER(given that it exists and has not been downloaded already) and stores it in the home directory

$ xkcd-dl --download=143
Downloading xkcd from 'http://xkcd.com/143/' and storing it under '/home/tasdik/xkcd_archive/143'
$ xkcd-dl --download=1603
Downloading xkcd from 'http://xkcd.com/1603/' and storing it under '/home/tasdik/xkcd_archive/1603'
xkcd  number '1603' has already been downloaded!
$

3.4   --download-range <START> <END>

Will take two number parameters and download all the xkcd's between the two, inclusive.

$ xkcd-dl --download-range 32 36
Downloading xkcd from 'http://xkcd.com/32/' and storing it under '/home/tasdik/xkcd_archive/32'
Downloading xkcd from 'http://xkcd.com/33/' and storing it under '/home/tasdik/xkcd_archive/33'
Downloading xkcd from 'http://xkcd.com/34/' and storing it under '/home/tasdik/xkcd_archive/34'
Downloading xkcd from 'http://xkcd.com/35/' and storing it under '/home/tasdik/xkcd_archive/35'
Downloading xkcd from 'http://xkcd.com/36/' and storing it under '/home/tasdik/xkcd_archive/36'

3.5   --download-all

As the name suggests, will download all the xkcd's uploaded till date and store them under the home directory of the user.

$ xkcd-dl --download-all
Downloading all xkcd's Till date!!
Downloading xkcd from 'http://xkcd.com/1466' and storing it under '/home/tasdik/xkcd_archive/1466'
Downloading xkcd from 'http://xkcd.com/381' and storing it under '/home/tasdik/xkcd_archive/381'
Downloading xkcd from 'http://xkcd.com/198' and storing it under '/home/tasdik/xkcd_archive/198'
Downloading xkcd from 'http://xkcd.com/512' and storing it under '/home/tasdik/xkcd_archive/512'
Downloading xkcd from 'http://xkcd.com/842' and storing it under '/home/tasdik/xkcd_archive/842'
Downloading xkcd from 'http://xkcd.com/920' and storing it under '/home/tasdik/xkcd_archive/920'
....
....

3.6   --path=PATH

To use a custom directory to store your xkcd_archive, you can append --path=./any/path/here to the end of any download method. Absolute and relative paths work, but the directory must already exist.

$ xkcd-dl --download=3 --path=comic
Downloading xkcd from 'http://xkcd.com/3/' and storing it under '/home/tasdik/comic/xkcd_archive/3'
$ xkcd-dl --download-range 54 56 --path=/home/tasdik/xkcd
Downloading xkcd from 'http://xkcd.com/54/' and storing it under '/home/tasdik/xkcd/xkcd_archive/54'
Downloading xkcd from 'http://xkcd.com/55/' and storing it under '/home/tasdik/xkcd/xkcd_archive/55'
Downloading xkcd from 'http://xkcd.com/56/' and storing it under '/home/tasdik/xkcd/xkcd_archive/56'

3.7   --show XKCD_NUM

Opens the specified comic. Downloads it, if not downloaded already. Prints the alt text and metadata to stdout.

$ xkcd-dl --show 32
Downloading xkcd from 'http://xkcd.com/32/' and storing it under '/home/bk/Documents/xkcd-dl/xkcd_dl/xkcd_archive/32'
title : Pillar
date-publised: 2006-1-1
url: http://xkcd.com/32/
alt: A comic by my brother Doug, redrawn and rewritten by me

$ xkcd-dl -s 1000
Downloading xkcd from 'http://xkcd.com/1000/' and storing it under '/home/bk/Documents/xkcd-dl/xkcd_dl/xkcd_archive/1000'
xkcd  number '1000' has already been downloaded!
title : 1000 Comics
date-publised: 2012-1-6
url: http://xkcd.com/1000/
alt: Thank you for making me feel less alone.

4   Installation

4.1   Option 1: installing through pip (Suggested way)

pypi package link

$ pip3 install xkcd-dl

If you are behind a proxy

$ pip3 --proxy [username:password@]domain_name:port install xkcd-dl

Note: If you get command not found then $ sudo apt-get install python3-pip should fix that

4.2   Option 2: installing from source

$ git clone https://github.com/tasdikrahman/xkcd-dl.git
$ cd xkcd-dl/
$ pip3 install -r requirements.txt
$ python3 setup.py install

4.3   Upgrading

$ pip3 install -U xkcd-dl

4.4   Uninstalling

$ pip3 uninstall xkcd-dl

4.5   For Arch distributions

Here is the AUR link for you

5   Contributing

I hacked this up in one night, so its a little messy up there. Feel free to contribute.

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-awesome-feature)
  3. Commit your changes (git commit -am 'Added <xyz> feature')
  4. Push to the branch (git push origin my-new-awesome-feature)
  5. Create new Pull Request

5.1   Contributors

Big shout out to

  • Ian C for fixing issue #2 which stopped the download if a title of a comic had a special character in it and BlitzKraft for pointing it out.
  • BlitzKraft for adding the feature to download the alt-text from the the xkcd and major clean ups!
  • Braden Best for pointing out the issues when installing from source apart from his valuable input.

5.2   To-do

  • [x] add xkcd-dl --download-latest
  • [x] add xkcd-dl --download=XKCDNUMBER
  • [x] add xkcd-dl --download-all
  • [x] add xkcd-dl download-range <START> <END>
  • [x] add path setting with [--path=/path/to/directory] option
  • [x] add exclude list to easily recognize and ignore dynamic comics i.e. comics without a default image.
  • [x] Remove redundant code in download_xkcd_number(), download_latest() and download_all() (Refactoring!!)
  • [x] Adding support to open a particular xkcd at the CLI itself. Implemented using xdg-open. Opens using your default image viewer.
  • [x] Add tests

5.3   Known Issues

  • There have been issues when installed from source if you are using python 2.* as discussed in #5. So using python3.* is suggested.
  • If you get command not found when installing, it may mean that you don't have pip3 installed. $ sudo apt-get install python3-pip should fix that. To check your version of pip
  • Dynamic comics have to be added manually using the excludeList
$ pip3 --version
pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)
$

5.4   Bugs

Please report the bugs at the issue tracker

OR

You can tweet me at @tasdikrahman if you can't get it to work. In fact, you should tweet me anyway.

6   Changelog

  • 0.1.2:
    bug: fixed relative import error in setup.py added support for gif files when renaming downloaded image (#38)

7   Motivation

xkcd-dl is inspired by an awesome package called youtube-dl written by Daniel Bolton (Much respect!)

How about you get to download all of the xkcd which have been uploaded till date? This does just that!

Now I don't know about you, but I just love reading xkcd's! Had a boring Sunday night looming over, thought why not create something like youtube-dl but for downloading xkcd's!

And hence xkcd-dl

Cheers to a crazy night!

8   Legal stuff

Built with by Tasdik Rahman (@tasdikrahman) and others released under MIT License

You can find a copy of the License at http://prodicus.mit-license.org/

9   Donation

If you have found my little bits of software of any use to you, you can help me pay my internet bills :)

Paypal badge

Instamojo

gratipay

patreon

More Repositories

1

vocabulary

[Not Maintained anymore] Python Module to get Meanings, Synonyms and what not for a given word
Python
559
star
2

spaceShooter

🎮 The classic retro game recreated using Pygame and python
Python
507
star
3

tnote

📋 A command line note taking app so simple that even your grandparents will love it!
Python
232
star
4

spammy

Spam filtering made easy for you
Python
141
star
5

plino

Flask based spam filtering system built on top of https://github.com/prodicus/spammy
CSS
74
star
6

terraform-gcp-examples

Terraform Google cloud platform examples
HCL
58
star
7

pyzipcode-cli

📬 Extract all possible meta data using Zipcode
Python
34
star
8

pyCalc

💻 A GUI Calculator using Tkinter
Python
31
star
9

easyrbac

RBAC0 implementation (core part)
Python
30
star
10

markovipy

Yet another markov chain sentence generator
Python
27
star
11

thanos

A dead simple demonstration of SQL injection in an SQLite database
Python
24
star
12

pygame-boilerplate

A dead simple pygame boilerplate
Python
22
star
13

movieReviewsAnalysis

Some stupid Movie reviews analyzed and classified using nltk and scikitlearn
Jupyter Notebook
20
star
14

ansible-bootstrap-server

the bare essentials when you spin up a server
Shell
17
star
15

spamfilter

DEPRECATED: Go to https://github.com/prodicus/spammy for DEV version
Python
14
star
16

bhola

Bhola tells it's overseer on when the certificates tracked by bhola are about to expire
Ruby
13
star
17

opencv_edge_detection

[WIP]
Python
10
star
18

margo

An opinionated Slack bot written for SRMSE's slack channel
Python
9
star
19

dotfiles

🔧
Shell
7
star
20

terraform-google-network

Terraform module : GCP : for creation of VPC network
HCL
5
star
21

cgi_login

a simple login system using CGIHTTPServer and sqlite3
Python
5
star
22

datasets

random public datasets encountered by me
4
star
23

terraform-google-network-subnet

Terraform module : GCP : for creation of subnet inside a VPC network
HCL
4
star
24

web_crawlers

as the name says
Python
3
star
25

foodoh

OUTDATED: Go to https://github.com/foodoh. Made a food recommendor system at Startup Weekend Chennai '15. Named it "foodoh"!
Python
3
star
26

terraform-google-network-firewall

Terraform module : GCP : for creation of firewall rules inside the VPC
HCL
3
star
27

tasdikrahman.me

NOTE: has been moved over to tasdikrahman.com
CSS
2
star
28

tasdikrahman.com

[wip] mirroring tasdikrahman.me for now.
CSS
2
star
29

srm_search_engine

OUTDATED: Head over to https://github.com/SRMSE
Python
2
star
30

opencv3-ansible-vagrant-playbook

Ansible playbook for configuring OpenCV 3.1.0 with python3 on top of a Ubuntu 14.04.05 vagrant box/your preferred cloud service (AWS/DO droplet etc.)
2
star
31

k8s-cluster-upgrade-tool

OSS release of the internal k8s cluster upgrade tooling we have
Go
2
star
32

test-goreleaser

testing goreleaser
Go
1
star
33

shivangidwivedi.com

shivangidwivedi.com
CSS
1
star
34

zshrc

My zshrc
Shell
1
star
35

go-whois

1
star
36

infra

my setup on DO for my homelab on k8s
HCL
1
star
37

btech-major-project-thesis

"Processing textual notes using advanced image processing techniques"
TeX
1
star
38

talks

contains the talks that I have given so far
Python
1
star
39

scripts

This lives in my ~/bin/scripts directory and is added to my $PATH.
1
star
40

docker-flask

Simple example of integrating docker with web apps
Python
1
star
41

kubecon-2017-notes

1
star