-
Notifications
You must be signed in to change notification settings - Fork 5
/
4chan-thread-archiver
57 lines (45 loc) · 1.72 KB
/
4chan-thread-archiver
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# coding: utf-8
# The Hydrus Network developer screwed around with this April 2013
# Part of the JSON-based-chanarchiver by Lawrence Wu, 2012/04/04
# Originally from https://github.com/socketubs/4chandownloader
# Rewritten to save in seperate images folder, download plain HTML, modularization, comments, and code cleanup
#
# Initial release Nov. 5, 2009
# v6 release Jan. 20, 2009
# http://cal.freeshell.org
#
# Refactor, update and Python package
# by Socketubs (http://socketubs.net/)
# 09-08-12
#
from include import threadarchiver
from docopt import docopt
doc = """4chan-thread-archiver, uses 4chan API to download thread images and/or
thumbnails, along with thread HTML, JSON, and a list of referenced external
links. Uses the py4chan library.
Usage:
4chan-thread-archiver <url> [--path=<string>] [--delay=<int>] [--nothumbs] [--thumbsonly]
4chan-thread-archiver -h | --help
4chan-thread-archiver -v | --version
Options:
--nothumbs Don't download thumbnails
--thumbsonly Download thumbnails, no images
--delay=<int> Delay between thread checks [default: 20]
-h --help Show help
-v --version Show version
"""
def print_as_function( text ): print( text )
def main(args):
# Copy data from arguments
thread = args.get('<url>').split('/')[5]
board = args.get('<url>').split('/')[3]
path = args.get('--path')
nothumbs = args.get('--nothumbs', False)
thumbsonly = args.get('--thumbsonly', False)
delay = args.get('--delay')
archiver = threadarchiver.Archiver( print_as_function )
Archiver.Archive( thread, board, path, notthumbs, thumbsonly, delay )
if __name__ == '__main__':
args = docopt(doc, version=0.3)
main(args)