Collects statistical data from 3d printing sites like Thingiverse, Cults3d or Printable
- 1. Installation
- 2. Usage
- 2.1. ds help
- 2.2. ds mergeSites command
- 2.3. ds importDesigns
- 2.4. ds updateStatistics command
- 2.5. ds show command
- 2.5.1. Execute ds show designs
- 2.5.2. Execute ds show designSources
- 2.5.3. Execute ds show dailySums
- 2.5.4. Execute ds show monthlySums
- 2.5.5. Execute ds show yearlySums
- 2.5.6. Execute ds show totalSums
- 2.5.7. Execute ds show designDaily
- 2.5.8. Execute ds show designMonthlySums
- 2.5.9. Execute ds show designYearlySums
- 2.5.10. Execute ds show designTotal
- 2.5.11. Execute ds show compareDailyDesignDownloads
- 2.5.12. Execute ds show compareMonthlyDesignDownloads
- 2.5.13. Execute ds show compareYearlyDesignDownloads
- 2.5.14. Execute ds show compareTotalDesignDownloads
- 2.5.15. Execute ds show designStatistics
- 2.5.16. Execute ds show sourceStatistics
- 2.5.17. ds show options
- 2.6. ds test command
# clone the repository
$ git clone https://github.com/WilkoV/design-stats.git
$ cd design-stats
Copy .env.template
to .env
and amend the values that look like <...>
.
cp config/.env.template config/.env
$ vi config/.env
# Install nodejs dependencies
$ npm install
# Install command globally
$ npm install -g
The installation can be tested with the ds test command. It will test the list and details connection to the different 3d printing sites, test the db connection and will query each table in the database.
After installation the command can be accessed by design-stats
or ds
. This document will use ds
.
# Show help and list of all commands
$ ds --help
# output:
Usage: ds [options] [command]
Collect statistical data from 3d printing sites
Options:
-V, --version output the version number
-h, --help show help
Commands:
test [options] [connectionType] Test connections to the database and 3d printing sites
mergeSites [options] Get list of user's Thingiverse designs and match them with designs from cults3d and printable
importDesigns [options] [importFile] Import design configurations for Thingiverse, cults3d and printable
help [command] display help for command
ds help [command]
shows the help of a specific command.
# Show help message for the test command
$ ds help test
# output
Usage: ds test [options] [connectionType]
Test connections to the database and 3d printing sites
Arguments:
connectionType Type of connection to test (choices: "thingiverse-api-details", "thingiverse-api-list", "cults3d-details",
"cults3d-list", "printable-details", "printable-list", "db", "all", default: "all")
Options:
-c, --config <configFile> config file path (default: "config/.env")
-h, --help display help for command
ds mergeSites
collects the designs from a user from the 3d printing sites and merges them into one file by title. Assuming the default base director is used it will create up t four files:
- data/export/merged-sites.json
- data/error/thingiverse-list.json
- data/error/cults3d-list.json
- data/error/printable-list.json
The command has the following options:
-c, --config \<configFile\>
By default the command uses the configuration fileconfig/.env
. This option allows to specify a different configuration file in a different location.-b, --baseDirectory \<baseDirectory\>
By default all exports are written to the base directorydata
. Depending on the content files are written to specific subdirectories.export
for the merged sources anderror
for failed merges. This option allows to specify a different base directory.
ds mergeSites
# output:
β Configuration loaded
β User's Thingiverse designs loaded. Found 165 designs
β Designs from Cults3d loaded. Found 165 designs
β Designs from Printable loaded. Found 165 designs
β 165 merged designs written to file data\export\merged-sites.json
Note: The command has to be run in an environment with an active display, because it will open a browser window to get the list of designs from Printable and Cults3d. In a headless environment the command will not work and produce an output like this:
β Configuration loaded
β User's Thingiverse designs loaded. Found 165 designs
β Failed to load designs from Cults3d. Error: Error: Failed to launch the browser process!
[21027:21027:0515/124837.215457:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[21027:21027:0515/124837.215501:ERROR:env.cc(226)] The platform failed to initialize. Exiting.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
Error: Failed to launch the browser process!
[21027:21027:0515/124837.215457:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[21027:21027:0515/124837.215501:ERROR:env.cc(226)] The platform failed to initialize. Exiting.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
ds importDesigns
imports the designs from the mergeSites file into the database. The command will create a new entry in the database for each design and for each source. Additionally imported and failed sources will be written to the base directory.Assuming the default base director is used it will create up t four files:
- data/export/importDesigns.json
- data/error/failed-importDesigns.json.json
The command has the following options:
-c, --config \<configFile\>
By default the command uses the configuration fileconfig/.env
. This option allows to specify a different configuration file in a different location.-b, --baseDirectory \<baseDirectory\>
By default all exports are written to the base directorydata
. Depending on the content files are written to specific subdirectories.export
for the imported designs and sources anderror
for failed imports. This option allows it to specify a different base directory.-m, --verifyMerged
By default sources with the processing statusmerged
are not verified because the assumption is, that they're generated by the mergeSites command. So by default those are excluded. By setting this option the processing statusmerged
will be ignored and they're treated like manually added entries.-f, --overwriteFailed
Same behavior as for the--verifyMerged
option but for processing statusFAILED*
. This is useful if an error file is used for imports.
$ ds importDesigns
# output:
β Configuration loaded
β Schema version is correct
β Read 165 designs from data/import/merged-sites.json
β 1/165: Imported Banana 02 from Cults3d
β 1/165: Imported Banana 02 from Printable
β 1/165: Imported Banana 02 from Thingiverse
...
β 165/165: Imported Raspberry Pi3 Model B Case from Cults3d
β 165/165: Imported Raspberry Pi3 Model B Case from Printable
β 165/165: Imported Raspberry Pi3 Model B Case from Thingiverse
β 165 imported designs written to file data/export/importDesigns.json
ds updateStatistics
updates the statistics for all configured designs from all sources in the database. It performs following steps per design / source:
- get the totals for downloads, likes, views, makes, remixes, comments, collections from the 3d printing sites:
- calculate the daily and periodical data
- store the data in the database. Following tables are used
- imports: This table contains the totals for each day. This table is used to calculate the daily data points and can be used to recalculate the statistic tables. 1 row per day / design / source.
- daily_statistics: This table contains the daily data points. 1 row per day / design / source.
- statistics: This table contains the periodical data points. 1 row per year / day / design / source / data point.
$ ds updateStatistics
# output:
β importDate is set to 2022-06-03
β Configuration loaded
β Schema version is correct
β Got 498 sources
β 1/498: Banana 02 from Cults3d processed
β 2/498: Banana 02 from Printables processed
β 3/498: Banana 02 from Thingiverse processed
...
β 34/498: Woodturning Bowl 06 (Sleeper Bowl) from Cults3d processed
β 35/498: Woodturning Bowl 06 (Sleeper Bowl) from Printables--> error: title is not valid --> retrying later
β 36/498: Woodturning Bowl 06 (Sleeper Bowl) from Thingiverse processed
β 37/498: Woodturning Vase 05 from Cults3d processed
...
β 498/498: Cookie Cutter Heart (1x1) from Thingiverse processed
β 35/498 (retry): Woodturning Bowl 06 (Sleeper Bowl) from Printables processed
TODO: Add output
$ ds updateStatistics --date 2022/06/02
# output:
β importDate is set to 2022/06/02
β Configuration loaded
β Schema version is correct
β Got 498 sources
...
$ ds updateStatistics --designId 86 --source Printables
# output:
β importDate is set to 2022-06-03
β Setting design ID filter to 86
β Setting source filter to Printables
β Configuration loaded
β Schema version is correct
β Got 1 sources
β 1/1: Stackable Planter (110mm) from Printables processed
$ ds updateStatistics --source Printables
# output:
β importDate is set to 2022-06-03
β Setting design ID filter to undefined
β Setting source filter to Printables
β Configuration loaded
β Schema version is correct
β Got 166 sources
β 1/166: Banana 02 from Printables processed
...
-c, --config \<configFile\>
By default the command uses the configuration fileconfig/.env
. This option allows to specify a different configuration file in a different location.-i, --importDate <importDate>
By default the command uses the current date. This option allows to specify a different date that is used during the update process. The date has to be in the formatYYYY/MM/DD
.-d, --design <designId>
By default the command updates all designs. This option allows to specify the database ID of a single design that is updated. A design can have multiple sources. To update a single source use the--source
option.-s, --source <sourceType>
By default the command updates all sources. This option allows to specify a single source that is updated. Valid sources are:Cults3d
,Printables
,Thingiverse
. To update a single design use the--design
option.
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
TODO: insert example
v = argument / h = option | deisginId | title | source | importDate | limit | showZeroRows | statisticsType |
---|---|---|---|---|---|---|---|
designs | β | β | |||||
designSources | β | β | β | ||||
dailySums | β | β | β | β | |||
monthlySums | β | β1 | β | β | |||
yearlySums | β | β2 | β | β | |||
totalSums | β | β | β | ||||
designDaily | β | β | β | β | β | β | |
designMonthlySums | β | β | β | β3 | β | β | |
designYearlySums | β | β | β | β4 | β | β | |
designTotal | β | β | β | β | β | ||
compareDailyDesignDownloads | β | β | β | β | β | β | |
compareMonthlyDesignDownloads | β | β | β | β5 | β | β | |
compareYearlyDesignDownloads | β | β | β | β6 | β | β | |
compareTotalDesignDownloads | β | β | β | β | β | ||
designStatistics | β | β | β | β | β | β | β |
sourceStatistics | β | β | β | β |
TODO: Add description for each option TODO: Add warning that unsupported options are ignored with a warning message
ds test
tests the connections to the database and the 3d printing sites used by design-stats. It can be used to test the configuration file or to quickly verify that the basic api and web scraping functions are working. By default the command uses the configuration file config/.env
. This can be changed with the "-c" or "--config" option.
# test all connections
$ ds test
# output:
β Configuration loaded
β Thingiverse test connection for details successful: {"source":"Thingiverse","source_id":5249332,"title":"Banana 01","downloads":126,"likes":13}
β Thingiverse test connection for lists successful: Found 165 designs. First design: {"title":"Banana 02","source_id":5250995}
β Cults3d test connection for details successful: {"source":"Cults3d","source_id":"carafe-01","title":"Carafe 01","downloads":"14","likes":"4"}
β Cults3d test connection for lists successful: Found 165 designs. First design: {"title":"Banana 02","source":"Cults3d","source_id":"banana-02-wilko"}
β Printable test connection for details successful: {"source":"Printable","source_id":"135167-banana-01","title":"Banana 01","downloads":"22","likes":"4"}
β Printable test connection for lists successful: Found 165 designs. First design: {"title":"Stand for Santa Sleigh & Reindeer Christmas Decoration","source":"Printable","source_id":"184313-stand-for-santa-sleigh-reindeer-christmas-decorati"}
β Database connection successfully tested at Thu Jun 02 2022 11:31:22 GMT+0200 (Central European Summer Time)
β Database schema version is 1
β Database table designs successfully tested with 166 entries
β Database table sources successfully tested with 498 entries
β Database table imports successfully tested with 996 entries
β Database table daily_statistics successfully tested with 996 entries
β Database table statistics successfully tested with 6972 entries
Note: Some test have to be executed in an environment with an active display, because it will open a browser window to get the list of designs from Printable and Cults3d. In a headless environment the command will not work and produce an output like this:
β Configuration loaded
β Thingiverse test connection for details successful: {"source":"Thingiverse","source_id":5249332,"title":"Banana 01","downloads":127,"likes":13}
β Thingiverse test connection for lists successful: Found 165 designs. First design: {"title":"Banana 02","source":"Thingiverse","source_id":5250995}
β Cults3d test connection for details successful: {"source":"Cults3d","source_id":"carafe-01","title":"Carafe 01","downloads":"14","likes":"4"}
β Cults3d test connection for lists failed: Error: Failed to launch the browser process!
[20696:20696:0515/124403.678533:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[20696:20696:0515/124403.678589:ERROR:env.cc(226)] The platform failed to initialize. Exiting.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
β Printable test connection for details successful: {"source":"Printable","source_id":"135167-banana-01","title":"Banana 01","downloads":"23","likes":"4"}
β Printable test connection for lists failed: Error: Failed to launch the browser process!
[20792:20792:0515/124407.563645:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[20792:20792:0515/124407.563677:ERROR:env.cc(226)] The platform failed to initialize. Exiting.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
β Database connection successfully tested at Fri May 20 2022 13:31:43 GMT+0200 (Central European Summer Time)
β Database connection successfully tested at Thu Jun 02 2022 11:31:22 GMT+0200 (Central European Summer Time)
β Database schema version is 1
β Database table designs successfully tested with 166 entries
β Database table sources successfully tested with 498 entries
β Database table imports successfully tested with 996 entries
β Database table daily_statistics successfully tested with 996 entries
β Database table statistics successfully tested with 6972 entries
To test a specific connection the connection type can be added to the command. Valid connection types are:
thingiverse-api-details
: test the connection to the Thingiverse API and get the details of a specific designthingiverse-api-list
: test the connection to the Thingiverse API and get the list of the user's designscults3d-details
: test the connection to the Cults 3d web site and scrape the details of a specific designcults3d-list
: test the connection to the Cults 3d web site and scrape the list of user's designsprintable-details
: test the connection to the Cults 3d web site and scrape the details of a specific designprintable-list
: test the connection to the Cults 3d web site and scrape the list of user's designsdb
: test the connection to the database and get the list of all designsall
: test all connections
# test all connections
$ ds test thingiverse-api-details
# output:
β Configuration loaded
β Thingiverse test connection successful: {"id":5249332,"title":"Banana 01","downloads":123,"likes":13}