Add batch support
[clinton/thingy_grabber.git] / README.md
1 # thingy_grabber
2 Script for archiving thingiverse things. Due to this being a glorified webscraper, it's going to be very fragile.
3
4 ## Usage:
5 ````
6 usage: thingy_grabber.py [-h] [-l {debug,info,warning}] [-d DIRECTORY] {collection,thing,user,batch,version} ...
7
8 positional arguments:
9 {collection,thing,user,batch,version}
10 Type of thing to download
11 collection Download an entire collection
12 thing Download a single thing.
13 user Download all things by a user
14 batch Perform multiple actions written in a text file
15 version Show the current version
16
17 optional arguments:
18 -h, --help show this help message and exit
19 -l {debug,info,warning}, --log-level {debug,info,warning}
20 level of logging desired
21 -d DIRECTORY, --directory DIRECTORY
22 Target directory to download into
23 ````
24
25 ### Things
26 `thingy_grabber.py thing thingid`
27 This will create a directory named after the title of the thing with the given ID and download the files into it.
28
29 ### Collections
30 `thingy_grabber.py collection user_name collection_name`
31 Where `user_name` is the name of the creator of the collection (not nes. your name!) and `collection_name` is the name of the collection you want.
32
33 This will create a series of directorys `user-collection/thing-name` for each thing in the collection.
34
35 If for some reason a download fails, it will get moved sideways to `thing-name-failed` - this way if you rerun it, it will only reattmpt any failed things.
36
37 ### User designs
38 `thingy_grabber.py user_name`
39 Where `user_name` is the name of a creator.
40
41 This will create a series of directories `user designs/thing-name` for each thing that user has designed.
42
43 If for some reason a download fails, it will get moved sideways to `thing-name-failed` - this way if you rerun it, it will only reattmpt any failed things.
44
45 ### Batch mode
46 `thingy_grabber.py batch batch_file`
47 This will load a given text file and parse it as a series of calls to this script. The script should be of the form `command arg1 ...`.
48 Be warned that there is currently NO validation that you have given a correct set of commands!
49
50 An example:
51 ````
52 thing 3670144
53 collection cwoac bike
54 user cwoac
55 ````
56
57 If you are using linux, you can just add an appropriate call to the crontab. If you are using windows, it's a bit more of a faff, but at least according to [https://www.technipages.com/scheduled-task-windows](this link), you should be able to with a command something like this (this is not tested!): `schtasks /create /tn thingy_grabber /tr "c:\path\to\thingy_grabber.py -d c:\path\to\output\directory batch c:\path\to\batchfile.txt" /sc weekly /d wed /st 13:00:00`
58 You may have to play with the quotation marks to make that work though.
59
60 ## Requirements
61 python3, beautifulsoup4, requests, lxml
62
63 ## Current features:
64 - can download an entire collection, creating seperate subdirs for each thing in the collection
65 - If you run it again with the same settings, it will check for updated files and only update what has changed. This should make it suitible for syncing a collection on a cronjob
66 - If there is an updated file, the old directory will be moved to `name_timestamp` where `timestamp` is the last upload time of the old files. The code will then copy unchanged files across and download any new ones.
67
68 ## Changelog
69 * v0.5.0
70 - better logging options
71 - batch mode
72 * v0.4.0
73 - Added a changelog
74 - Now download associated images
75 - support `-d` to specify base download directory
76
77 ## Todo features (maybe):
78 - log to file support
79 - less perfunctory error checking / handling
80 - attempt to use -failed dirs for resuming
81 - gui?
82