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

Handle embedded in HTML files #11

Open
obsessedcake opened this issue Jul 1, 2024 · 0 comments
Open

Handle embedded in HTML files #11

obsessedcake opened this issue Jul 1, 2024 · 0 comments

Comments

@obsessedcake
Copy link
Owner

@PxINKY found that Gumroad can embed directly into the page to allow creators to embed videos/images into the page, this result removes download_url from the item object.

To overcome this we can extract download URLs from raw HTML (like we did before in f30e7ef) and do something with them.

I've made a small utility method from to extract all files from raw HTML.

    def _get_all_files(self, soup: BeautifulSoup) -> dict[str, str]:    
        raw_files: dict[str, str] = {}
        for file in soup.find_all("div", attrs={"role": "treeitem"}, class_="js-file-list-element"):
            file_type = file.select_one("li:nth-child(1)").string.lower()
            file_name = file.select_one("h4").string
            file_url = self._session.base_url + file.select_one("a", href=True)["href"]

            raw_files[f"{file_name}.{file_type}"] = file_url

{file_name}.{file_type} - not the best key here because we can have many files with same name in different folders.

If I remember correctly, each file should have a unique id in JSON. If they use this "uid" in HTML then it's an easy go, otherwise meh...

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

1 participant