fishy / url2epub

Create ePub files from URLs
BSD 3-Clause "New" or "Revised" License
67 stars 7 forks source link

Failures on ChromeUnboxed articles #3

Closed fishy closed 3 years ago

fishy commented 3 years ago

Got errors in ChromeUnboxed articles with logs like this:

E tg_webhook.go:76: urlHandler: getEpub failed for "https://chromeunboxed.com/how-to-enable-nearby-sharing-in-chrome-os-87-right-now/": ziputil.WriteFile: unable to write "content/article.xhtml": html: void element <img> has child nodes

The reason is they use fallback amp-img tags:

<figure class="amp-featured-image ">
  <amp-img src="https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks.jpg" srcset="https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks.jpg 1920w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-300x169.jpg 300w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-1024x576.jpg 1024w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-768x432.jpg 768w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-1536x864.jpg 1536w" width="1920" height="1080" layout="responsive" alt="How to enable Nearby Sharing in Chrome OS 87 right now">
    <amp-img fallback="" src="https://chromeunboxed.com/wp-content/plugins/accelerated-mobile-pages/images/SD-default-image.png" srcset="https://chromeunboxed.com/wp-content/plugins/accelerated-mobile-pages/images/SD-default-image.png 1920w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-300x169.jpg 300w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-1024x576.jpg 1024w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-768x432.jpg 768w, https://chromeunboxed.com/wp-content/uploads/2020/04/AndroidNearbyShareChromeOSChromebooks-1536x864.jpg 1536w" width="1920" height="1080" layout="responsive" alt="How to enable Nearby Sharing in Chrome OS 87 right now">
    </amp-img>
  </amp-img>
</figure>

The solution would be to use ignore the childrens of an amp-img node.