Update readme

This commit is contained in:
Jérémi N ‘EndMove’ 2022-09-12 22:33:56 +02:00
parent b46ecacbd9
commit f47646c66b
Signed by: EndMove
GPG Key ID: 65C4A02E1F5371A4
3 changed files with 80 additions and 51 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
### Build ###
app_version_file.txt
### Python ### ### Python ###
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

View File

@ -1,22 +1,29 @@
# WebPicDownloader # WebPicDownloader
[![Donate][link-icon-coffee]][link-paypal-me] [![Website][link-icon-website]][link-website]
[link-icon-coffee]: https://img.shields.io/badge/%E2%98%95-Buy%20me%20a%20cup%20of%20coffee-991481.svg
[link-paypal-me]: https://www.paypal.me/EndMove/2.5eur
[link-icon-website]: https://img.shields.io/badge/%F0%9F%92%BB-My%20Web%20Site-0078D4.svg
[link-website]: https://www.endmove.eu/
## What is webpicdownloader ? ## What is webpicdownloader ?
WebPicDownloader is a scraping tool that allows you to download all the images of a website. Basically WebPic is a Python script around which a graphical interface has been added to make it easier to use. WebPicDownloader is a scraping tool that allows you to download all the images of a website. Basically WebPic is a Python script around which a graphical interface has been added to make it easier to use.
You will find [here](#windows-application) utility information to use the Windows application ``WebPicDownloader.exe``. And [here](#use-python-script) information to use or implement the Python script ``WebPicDownloader.py`` in your application (without the graphical interface). You will find [here](#windows-application) utility information to use the Windows application `WebPicDownloader.exe`. And [here](#use-python-script) information to use or implement the Python script `WebPicDownloader.py` in your application (without the graphical interface).
## Windows application ## Windows application
To use WebPic on windows nothing more simple, download the executable ``.exe`` of the last [release here](https://git.endmove.eu/EndMove/WebPicDownloader/releases) (be careful to download the latest release and not a pre-release). To use WebPic on windows nothing more simple, download the executable `.exe` of the last [release here](https://git.endmove.eu/EndMove/WebPicDownloader/releases) (be careful to download the latest release and not a pre-release).
Execute the file ``WebPicDownloader.exe`` and enjoy it! 👌 Execute the file ``WebPicDownloader.exe`` and enjoy it! 👌
## Use Python script ## Use Python script
To start, find the script to use or to add to your code [here](model/WebPicDownloader.py). To start, find the script to use or to add to your code [here](webpicdownloader/model/WebPicDownloader.py).
### Requirements ### CLI Run Requirements
To use the script check the following prerequisites. To use the script check the following prerequisites.
@ -27,12 +34,75 @@ To use the script check the following prerequisites.
### Console Use ? ### Console Use ?
If you just want to use the console version of the script without the built-in GUI then you just need to check the [prerequisites](#requirements) and run the script as follows: If you just want to use the console version of the script without the built-in GUI then you just need to check the [prerequisites](#cli-run-requirements) and run the script as follows:
```python ```python
python3 WebPicDownloader.py python3 WebPicDownloader.py
``` ```
### Integration to your code ? ### Integrate to your code ?
First of all you have to know that WebPic has a deamon worker that downloads all the images asynchronously (this allows you not to block your program when a download is in progress). This same worker will be automatically killed as soon as your program finishes. WebPic therefore provides a blocking stop function allowing you to wait for the end of the download. See the information below. First of all you have to know that WebPicDownloader has a deamon worker that downloads all the images asynchronously (this allows you not to block your program when a download is in progress). This same worker will be automatically killed as soon as your program finishes. WebPicDownloader therefore provides a blocking stop function allowing you to wait for the end of the download. See the information below. The prerequisites are the same as if you were running the script from the command line, see [prerequisites](#cli-run-requirements).
#### Step #1
Instantiate your WebPicDownloader object like this:
```python
from WebPicDownloader import WebPicDownlodaer, MessageType
webpic = WebPicDownloader()
```
The constructor can take several parameters (`path: str, headers: dict, messenger, success, failure`) (see the documentation).
#### Step #2
Define the WebPicDownloader callback functions. There are 3 main ones, the first (messenger callback) will be called at each system event and takes the following parameters (`message: str, type: MessageType`). The second (success callback) will be called at the end of processing if no major errors occur, it takes the following parameters (`message: str`). The third and last function (failure callback) will be called if a major error occurs or the download fails, it takes the following parameter (`message: str`).
By default, these functions print their results with a simple `print(message)` in the console. In case you implement WebPicDownloader in a graphical program, you should by convention remove all printing from your application and therefore define your own callback functions for WebpicDownloder. Below is an example:
```python
from WebPicDownloader import WebPicDownlodaer, MessageType
# Consider instantiating before the main loop of your program is launched.
webpic = WebPicDownloader()
# Pay attention to the signature of the functions
webpic.set_success_callback(lambda message: print(f"Success ! [{message}]."))
webpic.set_failure_callback(lambda message: print(f"Success ! [{message}]."))
webpic.set_messenger_callback(lambda message, msg_type: print(f"[{msg_type}]: {message}."))
```
#### Step #3
Once WebPicDownloader instantiated and the callback functions configured, we have to launch the download and stop it. It is important to know that the script does not have a function to stop a download in progress, in fact the stop function will allow you to wait for the end of the download and then turn off the program or to kill the worker automatically when the main thread dies.
```python
from time import sleep
from WebPicDownloader import WebPicDownlodaer, MessageType
webpic = WebPicDownloader()
# ... callbacks ...
# Webpic will give the task to its worker and start downloading the images
webpic.start_downloading('https://www.endmove.eu/', 'EndMove-website-images')
# We wait for the worker to start the task (once the task has started it cannot be stopped)
sleep(1)
# Webpic will ask the program to stop in blocking mode (it will join the worker to wait for the end of its execution)
webpic.stop_downloading(True)
```
## Improvement (TODO LIST)
Here you will find some improvements I would like to add to the program, you can also participate by forking the repository and submitting a pull request.
- [x] Check for updates button.
- [ ] Integrated file explorer.
- [ ] Viewing the downloads already made.
- [ ] Redo WebPicDownlodaer script to support concurrent downloads, to be able to launch workers and share tasks via a download pool.
This program is only a free utility tool and has not been developed in depth. In a future version it would be interesting to manage concurrent downloads in a thread pool.

View File

@ -1,44 +0,0 @@
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0. Must always contain 4 elements.
filevers=(1,0,0,0),
prodvers=(1,0,0,0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x40004,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904B0',
[StringStruct(u'CompanyName', u'EndMove Corp.'),
StringStruct(u'FileDescription', u'Scraping tool to recover all the images of a website.'),
StringStruct(u'FileVersion', u'1.0.0.0'),
StringStruct(u'InternalName', u'webpic'),
StringStruct(u'LegalCopyright', u'© Copyright 2022 EndMove. All rights reserved.'),
StringStruct(u'OriginalFilename', u'WebPicDownloader.exe'),
StringStruct(u'ProductName', u'WebPicDownloader'),
StringStruct(u'ProductVersion', u'1.0.0.0')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)