Skip to content

Commit

Permalink
update pixiv bookmark for http2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandaka committed Dec 20, 2022
1 parent 5cad4b2 commit 2fe5bb1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions PixivBookmarkHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def process_from_group(caller,
while flag:
url = f"https://www.pixiv.net/group/images.php?format=json&max_id={max_id}&id={group_id}"
PixivHelper.print_and_log('info', f"Getting images from: {url}")
response = br.open(url)
json_response = response.read()
response = br.open_with_retry(url)
json_response = response.text
response.close()
group_data = PixivGroup(json_response)
max_id = group_data.maxId
Expand Down Expand Up @@ -366,7 +366,7 @@ def get_bookmarks(caller, config, hide, start_page=1, end_page=0, member_id=None
PixivHelper.print_and_log('info', f"Source URL: {url}")

page = br.open_with_retry(url)
page_str = page.read().decode('utf8')
page_str = page.text
page.close()

bookmarks = PixivBookmark.parseBookmark(page_str,
Expand Down Expand Up @@ -417,8 +417,8 @@ def get_image_bookmark(caller, config, hide, start_page=1, end_page=0, tag=None,
PixivHelper.print_and_log('info', f"Using image tag: {tag}")

PixivHelper.print_and_log('info', f"Source URL: {url}")
page = br.open(url)
page_str = page.read().decode('utf8')
page = br.open_with_retry(url)
page_str = page.text
page.close()

if use_image_tag:
Expand Down
2 changes: 1 addition & 1 deletion PixivBrowserFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def getMemberInfoWhitecube(self, member_id, artist, bookmark=False):
info = self._get_from_cache(url)
if info is None:
res = self.open_with_retry(url)
infoStr = res.text # read()
infoStr = res.text
res.close()
info = json.loads(infoStr)
self._put_to_cache(url, info)
Expand Down
2 changes: 1 addition & 1 deletion PixivHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ def check_version(br, config=None):
import PixivBrowserFactory
br = PixivBrowserFactory.getBrowser(config=config)
result = br.open_with_retry("https://raw.githubusercontent.com/Nandaka/PixivUtil2/master/PixivConstant.py", retry=3)
page = result.read().decode('utf-8')
page = result.text
result.close()
latest_version_full = re.findall(r"PIXIVUTIL_VERSION = '(\d+)(.*)'", page)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ PySocks>=1.7.1
# requests>=2.22.0
# apng>=0.3.3
colorama>=0.4.4
cloudscraper>=1.2.58
cloudscraper
# pyexiv2>=2.7.0 # Required for writeImageXMP.
12 changes: 6 additions & 6 deletions test_PixivHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ def testCreateFilenameTranslatedTag(self):
expected2 = 'balzehn (267014)\\folder.png'

result2 = PixivHelper.make_filename(nameFormat2,
imageInfo,
artistInfo=None,
tagsSeparator=' ',
fileUrl='http://i2.pixiv.net/img16/img/balzehn/2493913.jpg',
useTranslatedTag=True,
tagTranslationLocale="en")
imageInfo,
artistInfo=None,
tagsSeparator=' ',
fileUrl='http://i2.pixiv.net/img16/img/balzehn/2493913.jpg',
useTranslatedTag=True,
tagTranslationLocale="en")
# #940
self.assertEqual(result2, expected2)

Expand Down
4 changes: 2 additions & 2 deletions test_updateHtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import getpass

import mechanize
import urllib3

import PixivBrowserFactory
import PixivConfig
Expand Down Expand Up @@ -54,7 +54,7 @@ def downloadPage(url, filename):
print("Dumping " + url + " to " + filename)
try:
html = __br__.open(url).read()
except mechanize.HTTPError as e:
except urllib3.HTTPError as e:
if e.code in [400, 403, 404]:
html = e.read()
else:
Expand Down

0 comments on commit 2fe5bb1

Please sign in to comment.