q6 commited on
Commit
89c01b2
·
1 Parent(s): 3143c68

Hyper pixif

Browse files
Files changed (2) hide show
  1. API/app.py +9 -2
  2. build_run_docker.bat +1 -0
API/app.py CHANGED
@@ -194,8 +194,13 @@ async def process_post(post_id, session, semaphore):
194
  try:
195
  data = await fetch_page(session, f"https://www.pixiv.net/ajax/illust/{post_id}/pages")
196
  image_urls = [page['urls']['original'] for page in data['body'] if 'png' in page['urls']['original']][:20]
197
- for image_url in image_urls:
198
- metadata = await get_exif(image_url, session)
 
 
 
 
 
199
  exif_type = determine_exif_type(metadata)
200
  if exif_type not in ['photoshop', 'celsys', None]:
201
  return post_id, image_url
@@ -203,6 +208,7 @@ async def process_post(post_id, session, semaphore):
203
  except Exception as e:
204
  return post_id, None
205
 
 
206
  @app.post("/pixif")
207
  async def pixif(
208
  items: pixifModel
@@ -217,6 +223,7 @@ async def pixif(
217
  image_exifs = {post_id: image_url.replace('https://i.pximg.net/img-original/', '', 1) for post_id, image_url in results if image_url}
218
  return image_exifs
219
 
 
220
  async def generate_zip(posts, session):
221
  zip_buffer = io.BytesIO()
222
  zipf = zipfile.ZipFile(zip_buffer, mode="w", compression=zipfile.ZIP_DEFLATED)
 
194
  try:
195
  data = await fetch_page(session, f"https://www.pixiv.net/ajax/illust/{post_id}/pages")
196
  image_urls = [page['urls']['original'] for page in data['body'] if 'png' in page['urls']['original']][:20]
197
+
198
+ # Create tasks to fetch EXIF data for all image URLs
199
+ tasks = [get_exif(image_url, session) for image_url in image_urls]
200
+ exif_data_list = await asyncio.gather(*tasks)
201
+
202
+ # Process EXIF data to find the earliest matching image per post ID
203
+ for image_url, metadata in zip(image_urls, exif_data_list):
204
  exif_type = determine_exif_type(metadata)
205
  if exif_type not in ['photoshop', 'celsys', None]:
206
  return post_id, image_url
 
208
  except Exception as e:
209
  return post_id, None
210
 
211
+
212
  @app.post("/pixif")
213
  async def pixif(
214
  items: pixifModel
 
223
  image_exifs = {post_id: image_url.replace('https://i.pximg.net/img-original/', '', 1) for post_id, image_url in results if image_url}
224
  return image_exifs
225
 
226
+
227
  async def generate_zip(posts, session):
228
  zip_buffer = io.BytesIO()
229
  zipf = zipfile.ZipFile(zip_buffer, mode="w", compression=zipfile.ZIP_DEFLATED)
build_run_docker.bat ADDED
@@ -0,0 +1 @@
 
 
1
+ build_docker.bat & run_docker.bat