• Stars
    star
    171
  • Rank 222,266 (Top 5 %)
  • Language
    Python
  • License
    BSD 2-Clause "Sim...
  • Created almost 11 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

Simple, fast command-line tool to get photos from Twitter accounts

Twitter Photos

https://img.shields.io/pypi/v/twitter-photos.png https://travis-ci.org/shichao-an/twitter-photos.png?branch=master

Twitter Photos is a command-line tool to get photos from Twitter accounts.

https://asciinema.org/a/93714.png

Requirements

  • python-twitter
  • requests
  • urllib3

Installation

You can install the package with pip:

$ pip install twitter-photos

Or, you can download a source distribution and install with these commands:

$ python setup.py install

How It Works

The command-line front-end of Twitter Photos, "twphotos", downloads photos from specified Twitter accounts into individual directories each named after username. It hits the Twitter API as little as possible to retrieve photos links and download each link separately. You can view the links yourself and pipe them to other programs such as wget. You can specifiy photo size, number of photos to get, and whether to download only new photos since last downloads.

Setup

Create a config file at ~/.twphotos specifying your Twitter credentials (you can create an app and get your keys at Twitter Application Management):

[credentials]
consumer_key = your_consumer_key
consumer_secret = your_consumer_secret
access_token_key = your_access_token_key
access_token_secret = your_access_token_secret

Note that the values on the right side of = should not contain the quotes; they are just themselves since this file is in INI format.

Usage

The simplest usage is to run "twphotos" from command-line without any options. This will download all photos from the current authenticated user (you):

$ twphotos

Download all photos from an existing user other than yourself with -u option followed by username. "twphotos" will automatically create a directory with the specified username and put downloaded photos in there:

$ twphotos -u wired

Download n most recent photos from a user using -n followed by number:

$ twphotos -u wired -n 20

Download photos to a directory other than the current one:

$ twphotos -u wired -o /path/to/dir

Enable "incremental download" to download new photos since the last downloads with -i:

$ twphotos -u wired -i

Enable "parallel download" to speedup the downloads using the -r switch:

$ twphotos -u wired -r

Print username, tweet ids, and URLs instead of downloading them with -p switch:

$ twphotos -u wired -p

Exclude replies tweets using -e switch:

$ twphotos -u wired -e

Download small-sized photos

$ twphotos -u wired -s small

You can retrieve URLs only with cut command:

$ twphotos -u wired -p | cut -d ' ' -f3

Command-line Options

The "twphotos" command accepts the following options:

-u USER, --user USER
 user account
-l LIST_SLUG, --list LIST_SLUG
 list slug with --user as list owner
-o OUTDIR, --outdir OUTDIR
 output directory
-p, --print print media urls and tweet ids instead of download
-r, --parallel enable parallel download
-n NUM, --num NUM
 number of most recent photos to download
-i, --increment
 download only new photos since last download
-e, --exclude_replies
 exclude replies
-s SIZE, --size SIZE
 photo size (orig, large, medium, small and thumb)
-t TYPE, --type TYPE
 timeline type (user and favorites)

More Repositories

1

notes

Shichao's Notes
HTML
1,097
star
2

leetcode-python

LeetCode problems in Python
Python
494
star
3

ooc

Object-Oriented Programming With ANSI-C
C
248
star
4

115wangpan

(Deprecated) Unofficial Python API wrapper SDK for 115.com (115网盘)
Python
106
star
5

soundmeter

Simple real-time sound meter
Python
81
star
6

homura

Python downloader with progress
Python
40
star
7

leetcode-ruby

LeetCode problems in Ruby
Ruby
31
star
8

examples_unix

Mastering Algorithms with C
C
28
star
9

hacking

Hacking: The Art of Exploitation, 2nd Edition
C
23
star
10

apue.3e

Advanced Programming in the UNIX® Environment, Third Edition
C
14
star
11

unpv13e

Unix Network Programming, Volume 1: The Sockets Networking API (3rd Edition)
C
11
star
12

procps-ng-3.3.10

procps-ng-3.3.10
C
10
star
13

momo

Simple file manager that organizes scattered files and resources
Python
5
star
14

GeoPort

Django-based geo-social platform
Python
3
star
15

docker-shadowsocks-libev

Dockerized shadowsocks-libev
Shell
3
star
16

tlpi-dist

The Linux Programming Interface
C
2
star
17

glibc-2.21

The GNU C Library (glibc) 2.21
C
2
star
18

uhuf

CLI tool to get GitLab repository files using API
Shell
2
star
19

ctci

Cracking the Coding Interview (5th Edition) problems
Python
2
star
20

PPP

Python and Parallel Programming
Python
2
star
21

adium-sh

The missing shell for Adium
Python
2
star
22

rsa

RSA cryptosystem
C
2
star
23

twtg

The Way to Go - Code Examples and Exercises
Go
2
star
24

blog-source

Tinkerer source code for blog
Python
2
star
25

practice

Data structures, algorithms and hacks for practice
Python
2
star
26

blog

Shichao's Blog
HTML
1
star
27

hello

GNU Hello
C
1
star
28

screen-lftp

Helper tool to lftp mirror
Shell
1
star
29

bash-4.3

GNU Bash 4.3
C
1
star
30

dot-vim

.vim and .vimrc
Vim Script
1
star
31

tcp-fsm

Finite-state machine of TCP
Python
1
star
32

hbc

HandBrake Cutter
Shell
1
star
33

udp-pinger

A simple UDP pinger
Python
1
star
34

pystress

Simple CPU stresser in Python
Python
1
star
35

otomad

Oto MAD
1
star