Commit | Line | Data |
---|---|---|
4f6e317c | 1 | # thingy_grabber |
975060c9 OM |
2 | Script for archiving thingiverse things. Due to this being a glorified webscraper, it's going to be very fragile. |
3 | ||
4 | ## Usage: | |
4a98996b | 5 | ```` |
4f94efc8 | 6 | usage: thingy_grabber.py [-h] [-l {debug,info,warning}] [-d DIRECTORY] [-f LOG_FILE] {collection,thing,user,batch,version} ... |
a7152c35 | 7 | |
4a98996b | 8 | positional arguments: |
1ab49020 | 9 | {collection,thing,user,batch,version} |
3522a3bf | 10 | Type of thing to download |
b7bfef68 | 11 | collection Download one or more entire collection(s) |
3522a3bf | 12 | thing Download a single thing. |
b7bfef68 | 13 | user Download all things by one or more users |
1ab49020 | 14 | batch Perform multiple actions written in a text file |
db8066ec | 15 | version Show the current version |
4a98996b OM |
16 | |
17 | optional 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 | |
4f94efc8 OM |
23 | -f LOG_FILE, --log-file LOG_FILE |
24 | Place to log debug information to | |
4a98996b | 25 | ```` |
3522a3bf | 26 | |
4a98996b | 27 | ### Things |
b7bfef68 OM |
28 | `thingy_grabber.py thing thingid1 thingid2 ...` |
29 | This will create a directory named after the title of the thing(s) with the given ID(s) and download the files into it. | |
4a98996b | 30 | |
4a98996b | 31 | ### Collections |
b7bfef68 OM |
32 | `thingy_grabber.py collection user_name collection_name1 collection_name2` |
33 | Where `user_name` is the name of the creator of the collection (not nes. your name!) and `collection_name1...etc` are the name(s) of the collection(s) you want. | |
975060c9 | 34 | |
a7152c35 | 35 | This will create a series of directorys `user-collection/thing-name` for each thing in the collection. |
a7152c35 OM |
36 | |
37 | 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. | |
38 | ||
3522a3bf | 39 | ### User designs |
b7bfef68 OM |
40 | `thingy_grabber.py user user_name1, user_name2..` |
41 | Where `user_name1.. ` are the names of creator. | |
3522a3bf OM |
42 | |
43 | This will create a series of directories `user designs/thing-name` for each thing that user has designed. | |
44 | ||
45 | 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. | |
46 | ||
1ab49020 OM |
47 | ### Batch mode |
48 | `thingy_grabber.py batch batch_file` | |
49 | 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 ...`. | |
50 | Be warned that there is currently NO validation that you have given a correct set of commands! | |
51 | ||
52 | An example: | |
53 | ```` | |
54 | thing 3670144 | |
55 | collection cwoac bike | |
56 | user cwoac | |
57 | ```` | |
58 | ||
59 | 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` | |
60 | You may have to play with the quotation marks to make that work though. | |
61 | ||
b7bfef68 OM |
62 | ## Examples |
63 | `thingy_grabber.py collection cwoac bike` | |
64 | Download the collection 'bike' by the user 'cwoac' | |
65 | `thingy_grabber.py -d downloads -l warning thing 1234 4321 1232` | |
66 | Download the three things 1234, 4321 and 1232 into the directory downloads. Only give warnings. | |
67 | `thingy_grabber.py -d c:\downloads -l debug user jim bob` | |
68 | Download all designs by jim and bob into directories under `c:\downloads`, give lots of debug messages | |
69 | ` | |
70 | ||
975060c9 | 71 | ## Requirements |
c4388960 | 72 | python3, beautifulsoup4, requests, lxml |
975060c9 OM |
73 | |
74 | ## Current features: | |
75 | - can download an entire collection, creating seperate subdirs for each thing in the collection | |
e36c2a07 | 76 | - 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 | 77 | - 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 | 78 | |
680039fe | 79 | ## Changelog |
4f94efc8 OM |
80 | * v0.6.3 |
81 | - Caught edge case involving old dir clashes | |
82 | - Add support for seperate log file | |
e0e69fc6 OM |
83 | * v0.6.2 |
84 | - Added catches for 404s, 504s and malformed pages | |
4f75dd69 OM |
85 | * v0.6.1 |
86 | - now downloads readme.txt and licence details | |
b7bfef68 OM |
87 | * v0.6.0 |
88 | - added support for downloading multiple things/design sets/collections from the command line | |
fa2f3251 OM |
89 | * v0.5.0 |
90 | - better logging options | |
1ab49020 | 91 | - batch mode |
680039fe OM |
92 | * v0.4.0 |
93 | - Added a changelog | |
94 | - Now download associated images | |
95 | - support `-d` to specify base download directory | |
e36c2a07 OM |
96 | |
97 | ## Todo features (maybe): | |
a7152c35 | 98 | - attempt to use -failed dirs for resuming |
1ab49020 | 99 | - gui? |
680039fe | 100 |