Updated readme
This commit is contained in:
parent
2232f289f0
commit
a882dfc743
79
README.md
79
README.md
@ -1,3 +1,78 @@
|
|||||||
# InstructionsDownloader
|
# Instruction Downloader Script
|
||||||
|
|
||||||
Script to download LEGO instructions
|
This Python script is designed to download LEGO building instructions for a given set ID from the Rebrickable website. It will search for all available instruction links related to a set, and based on the presence of a "V29" (or "V 29") tag in the alt text, it will download specific versions of the instructions.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Download Specific Versions**: Automatically handles downloading of instructions based on the `V29` version.
|
||||||
|
- **Handle Complex Alt Text**: The script handles alt text that includes variations like `V29`, including `x/y` patterns and ignores invalid patterns.
|
||||||
|
- **Fallback for Missing or Invalid V29 Versions**: If no valid V29 instruction links are found, the script will download all available instructions.
|
||||||
|
- **Customizable Download Filenames**: Instructions are saved with filenames based on the set ID and the instruction variant.
|
||||||
|
- **User-Agent Spoofing**: The script mimics a browser request to avoid being blocked as a bot.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Python 3.x
|
||||||
|
- `requests` library
|
||||||
|
- `beautifulsoup4` library
|
||||||
|
|
||||||
|
You can install the required dependencies by running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 -m pip install requests beautifulsoup4
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Running the Script
|
||||||
|
|
||||||
|
To use this script, you need to provide the LEGO set ID as an argument. The set ID is typically in the format `####-1` (e.g., `10313-1`).
|
||||||
|
|
||||||
|
### Example Command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 dl.py 10313-1
|
||||||
|
```
|
||||||
|
|
||||||
|
This will download the LEGO building instructions for the set `10313-1` (Wildflower Bouquet).
|
||||||
|
|
||||||
|
### How It Works
|
||||||
|
|
||||||
|
1. The script will visit the Rebrickable page for the provided set ID.
|
||||||
|
2. It will search for all available instruction links containing "LEGO Building Instructions" in the `alt` text.
|
||||||
|
3. If links with "V29" are found, the script will download them in order, naming them as `{set_id}+1.pdf`, `{set_id}+2.pdf`, etc.
|
||||||
|
4. If the `x/y` values in the `alt` text are invalid (i.e., `x` or `y` greater than 10), those links will be ignored.
|
||||||
|
5. If no valid `V29` links are found, the script will fall back to downloading all available instruction links, with filenames based on the alt text.
|
||||||
|
|
||||||
|
## Script Output
|
||||||
|
|
||||||
|
The script will print status messages during the execution, including:
|
||||||
|
|
||||||
|
- URLs of the files being downloaded.
|
||||||
|
- The filenames that the instructions will be saved as.
|
||||||
|
- Any errors encountered while downloading.
|
||||||
|
|
||||||
|
## Example Output
|
||||||
|
|
||||||
|
```bash
|
||||||
|
Downloading: https://rebrickable.com/instructions/10313-1/123456/download/?expire=1737409263 -> 10313+1.pdf
|
||||||
|
Saved: 10313+1.pdf
|
||||||
|
Downloading: https://rebrickable.com/instructions/10313-1/789012/download/?expire=1737409263 -> 10313+2.pdf
|
||||||
|
Saved: 10313+2.pdf
|
||||||
|
```
|
||||||
|
|
||||||
|
If no valid `V29` links are found, the script will print out the available instruction links.
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
- If the page cannot be loaded (e.g., invalid set ID), the script will print an error message and stop.
|
||||||
|
- If an instruction download fails, the script will print an error message with the HTTP status code.
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
- **User-Agent**: The script uses a browser-like User-Agent string to avoid being detected as a bot. You can customize the `headers` variable if needed.
|
||||||
|
- **Download Filename Format**: The filenames for the downloaded instructions are automatically generated. You can modify the `download_instructions` function to change the naming convention.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
Loading…
Reference in New Issue
Block a user