-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance document #1197
Enhance document #1197
Conversation
What on earth? |
the document, the readme.md. those settings are not used at all or having issues. |
Is the document you are referring to is the Readme.md?
|
right.
turned both on, but no '..-raw.text' file written, only a json.text from 'writeImageJSON'
it's created by .py when no config found
system use time in seconds since the epoch (i.e. UTC) always. tzinfo is usually useful only in string format and time calculation. Line 434 in f2e9ab1
so useLocalTimezone may be no need.
I think maybe adding a few examples will help. I want details of the 'checkfilesize' 'overwrite' and 'etc.' too since they are important to control downloading |
some more useful info that I think can help users and enhance document:
Line 1045 in f2e9ab1
this line extracted all files from the ugoira. it can directly convert from the source file .zip to all other formats actually, I guess.
"to encode webm" ==> "to encode webp". Line 1014 in f2e9ab1
webp can use lossless for the best quality by default. checkLastModified: when found db record and both PixivUtil2/PixivDownloadHandler.py Line 75 in 2699125
it should do the time check after finding the file size is the same. alwaysCheckFileSize: when found db record, if both this and overwrite are false, it will only check if the file exists at the recorded path. otherwise, it'll always do a file size check. overwrite: need |
will https://github.com/Nandaka/PixivUtil2/blob/f2e9ab19fe471c93c0a1697d89f1f9f93f3c39cd/PixivBrowserFactory.py#L60 be affected by the socks5 `getaddrd failed`?
readme.md
Outdated
@@ -528,7 +528,7 @@ Please refer run with `--help` for latest information. | |||
Set to `True` to export the image information to a .XMP sidecar file, one per image in the album. The data contained within the file is the same but some software requires matching file names to detect the metadata. If set to `True`, then `writeImageXMP` is ignored. | |||
- verifyimage | |||
|
|||
Do image and zip checking after download. Set the value to `True` to enable. | |||
Check if downloaded files is valid image or zip. Set the value to `True` to enable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If "files" is plural, the proper term to use would be "are", so Check if downloaded files are a valid image or zip
, however this is not what verifyimage
actually does. verifyimage
simply checks if the file ends in ".jpg", ".png", ".gif", ".ugoira", or ".zip". It does not verify if it is a valid image or zip file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mistake.
that adding details is trying to make it easier to tweak PixivUtil2 for experienced users.
actually, verifyimage
will validate files:
PixivUtil2/PixivDownloadHandler.py
Lines 203 to 248 in f2e9ab1
elif config.verifyImage and filename_save.endswith((".jpg", ".png", ".gif")): | |
fp = None | |
try: | |
from PIL import Image, ImageFile | |
fp = open(filename_save, "rb") | |
# Fix Issue #269, refer to https://stackoverflow.com/a/42682508 | |
ImageFile.LOAD_TRUNCATED_IMAGES = True | |
img = Image.open(fp) | |
img.load() | |
fp.close() | |
PixivHelper.print_and_log('info', ' Image verified.') | |
except BaseException: | |
if fp is not None: | |
fp.close() | |
PixivHelper.print_and_log('info', ' Image invalid, deleting...') | |
os.remove(filename_save) | |
raise | |
elif config.verifyImage and filename_save.endswith((".ugoira", ".zip")): | |
fp = None | |
try: | |
import zipfile | |
fp = open(filename_save, "rb") | |
zf = zipfile.ZipFile(fp) | |
check_result = None | |
try: | |
check_result = zf.testzip() | |
# Issue #1165 | |
except NotImplementedError as ne: | |
PixivHelper.print_and_log('warn', f' {ne}') | |
except RuntimeError as e: | |
if 'encrypted' in str(e): | |
PixivHelper.print_and_log('info', ' archive is encrypted, cannot verify.') | |
else: | |
raise | |
fp.close() | |
if check_result is None: | |
PixivHelper.print_and_log('info', ' Image verified.') | |
else: | |
PixivHelper.print_and_log('info', f' Corrupted file in archive: {check_result}.') | |
raise PixivException(f"Incomplete Downloaded for {url}", PixivException.DOWNLOAD_FAILED_OTHER) | |
except BaseException: | |
if fp is not None: | |
fp.close() | |
PixivHelper.print_and_log('info', ' Image invalid, deleting...') | |
os.remove(filename_save) | |
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh so it does, my mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that the overwrite
and alwaysCheckFileSize
have too much tech debt.
and not sure how to detail those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, it is from 2015 and no major rewrite at all. As long it is working as my expectation, I don't plan to do anything as long it doesn't break.
also send a lot of changes in one big pull request, i might not be able to understand it 😄 |
This PR will try to improve the document only, to make both new and experienced users clear with some details. |
The rest of this PR is done. Except the @Nandaka Can you add its document? |
Did you notice |
@cglmrfreeman it's updated now. |
@@ -223,7 +223,7 @@ def proxy(self): | |||
value = getattr(self, "proxyAddress", None) | |||
if not value: | |||
return None | |||
match = re.match(r"^(?:(https?|socks[45])://)?([\w.-]+)(:\d+)?$", value) | |||
match = re.match(r"^(?:(https?|socks[45]h?)://)?([\w.-]+)(:\d+)?$", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add check for socks4a too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can. But I don't have any socks4a server for test.
This PR tries to update the document and add some details to it.
Found some issues that need to discuss:
customCleanUpRe
no document.customBadChars
no code no use.writeRawJSON
no code no use.writeSeriesJSON
no code no use. theincludeSeriesJSON
do the job.useLocalTimezone
can be removed since all file time is always use local time.hope this can make the document better for coming new users