Skip to content
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

Can't unzip some zip files #925

Open
cyber-sec0 opened this issue May 9, 2024 · 2 comments
Open

Can't unzip some zip files #925

cyber-sec0 opened this issue May 9, 2024 · 2 comments

Comments

@cyber-sec0
Copy link

cyber-sec0 commented May 9, 2024

Apparently, there are some zip files that the library is unable to unzip? I tested them with Winrar and it worked...

On the website https://subdl.com/subtitle/sd20172/white-chicks
Both files below can't be unzipped by the library for some reason

English (Dvdrip)
White.Chicks.DVDRip.XViD-DvP (by: Sinistral)
White Chicks [Eng No Subtitles] [DVDrip] (by: uttamyadav)

`
// ==UserScript==
// @name Zip Extractor - SubDL
// @namespace https://greasyfork.org/en/users/
// @Version 1
// @description Automatically extract the subtitle file before downloading
// @author me
// @match https://subdl.com/subtitle/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js
// @grant none
// ==/UserScript==

(function() {
'use strict';
let pendingDownloadUrl = null; //Variable to store the URL of the pending download URL

document.addEventListener('mousedown', function(event) { //Listen for clicks on the page
pendingDownloadUrl = event.target.href; //Capture the download URL
}); //Finishes the mousedown event listener

document.addEventListener('click', function(event) { // Intercept clicks on the page
if (pendingDownloadUrl) { //If the element clicked was a link
event.preventDefault(); //Prevent the default .zip file download

  fetch(pendingDownloadUrl) //Fetch the .zip file
    .then(response => { //Check if the response headers indicate a zip file
    const contentType = response.headers.get('content-type');
    return response.blob();
  }).then(blob => { //Extract the contents of the zip file
    JSZip.loadAsync(blob).then(zip => { //Extract each file
      zip.forEach((relativePath, zipEntry) => {
        zipEntry.async('blob').then(content => {
          var a = document.createElement('a'); //Create a temporary link to download the extracted file
          a.href = URL.createObjectURL(content);
          a.download = zipEntry.name; //Use the original file name
          document.body.appendChild(a);
          a.click(); //Simulate a click to trigger the download
          document.body.removeChild(a);
        });
      });
    }).catch(error => {
      document.title = 'Error extracting zip file: ' + error; //Update the document title with error message
    });
  })

  pendingDownloadUrl = null; //Reset the pending download URL
}

});
})();
`

@mwildam
Copy link

mwildam commented Jun 5, 2024

Looks like I have the same issue. Did not yet found out the exact zip, but I have a node project that fails building using the latest version 3.10.1. I tested with several versions and found out, that must be a change from v3.3.0 to v3.4.0 that causes the issue.

@zyyzyykk
Copy link

zyyzyykk commented Aug 3, 2024

Not only zip, other formats such as img are also damaged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants