Add batch support
[clinton/thingy_grabber.git] / README.md
CommitLineData
4f6e317c 1# thingy_grabber
975060c9
OM
2Script for archiving thingiverse things. Due to this being a glorified webscraper, it's going to be very fragile.
3
4## Usage:
4a98996b 5````
1ab49020 6usage: thingy_grabber.py [-h] [-l {debug,info,warning}] [-d DIRECTORY] {collection,thing,user,batch,version} ...
a7152c35 7
4a98996b 8positional arguments:
1ab49020 9 {collection,thing,user,batch,version}
3522a3bf
OM
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
1ab49020 14 batch Perform multiple actions written in a text file
db8066ec 15 version Show the current version
4a98996b
OM
16
17optional arguments:
3522a3bf 18 -h, --help show this help message and exit
fa2f3251
OM
19 -l {debug,info,warning}, --log-level {debug,info,warning}
20 level of logging desired
d66f1f78
OM
21 -d DIRECTORY, --directory DIRECTORY
22 Target directory to download into
4a98996b 23````
3522a3bf 24
4a98996b
OM
25### Things
26`thingy_grabber.py thing thingid`
27This will create a directory named after the title of the thing with the given ID and download the files into it.
28
4a98996b 29### Collections
3522a3bf 30`thingy_grabber.py collection user_name collection_name`
975060c9
OM
31Where `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
a7152c35 33This will create a series of directorys `user-collection/thing-name` for each thing in the collection.
a7152c35
OM
34
35If 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
3522a3bf
OM
37### User designs
38`thingy_grabber.py user_name`
39Where `user_name` is the name of a creator.
40
41This will create a series of directories `user designs/thing-name` for each thing that user has designed.
42
43If 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
1ab49020
OM
45### Batch mode
46`thingy_grabber.py batch batch_file`
47This 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 ...`.
48Be warned that there is currently NO validation that you have given a correct set of commands!
49
50An example:
51````
52thing 3670144
53collection cwoac bike
54user cwoac
55````
56
57If 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`
58You may have to play with the quotation marks to make that work though.
59
975060c9 60## Requirements
c4388960 61python3, beautifulsoup4, requests, lxml
975060c9
OM
62
63## Current features:
64- can download an entire collection, creating seperate subdirs for each thing in the collection
e36c2a07 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
3c82f75b 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.
975060c9 67
680039fe 68## Changelog
fa2f3251
OM
69* v0.5.0
70 - better logging options
1ab49020 71 - batch mode
680039fe
OM
72* v0.4.0
73 - Added a changelog
74 - Now download associated images
75 - support `-d` to specify base download directory
e36c2a07
OM
76
77## Todo features (maybe):
1ab49020 78- log to file support
975060c9 79- less perfunctory error checking / handling
a7152c35 80- attempt to use -failed dirs for resuming
1ab49020 81- gui?
680039fe 82