MonkeyMaster64/Reddit-User-Media-Downloader-Public

Code does not gracefully handle 404 pages

bstincer opened this issue · 1 comments

For some imgur pages, when 404 is hit, file is downloaded, and file is not image/video, seems to be filled with only html code:

Example

Filename: 2021-05-25T102021-EDGEi8B
Contents:
<!doctype html> <title>I'll scrunch my nose, you make me scrunch my toes? - Album on Imgur</title> <script>dataLayer=[];var pbjs=pbjs||{};pbjs.que=pbjs.que||[]</script> <script async="true">!function(){var e=document.createElement("script"),t=document.getElementsByTagName("script")[0],n="https://quantcast.mgr.consensu.org".concat("/choice/","f8oruOqDFlMeI","/","imgur.com","/choice.js"),i=0;e.async=!0,e.type="text/javascript",e.src=n,e.onload=function(){var e=document.createEvent("Event");e.initEvent("cmpLoaded",!0,!0),window.dispatchEvent(e)},t.parentNode.insertBefore(e,t),function(){for(var e,a="__tcfapiLocator",i=[],o=window;o;){try{if(o.frames[a]){e=o;break}}catch(e){}if(o===window.top)break;o=o.parent}e||(function e(){var t=o.document,n=!!o.frames[a];if(!n)if(t.body){var i=t.createElement("iframe");i.style.cssText="display:none",i.name=a,t.body.appendChild(i)}else setTimeout(e,5);return!n}(),o.__tcfapi=function(){var e,t=arguments;if(!t.length)return i;if("setGdprApplies"===t[0])3<t.length&&2===t[2]&&"boolean"==typeof t[3]&&(e=t[3],"function"==typeof t[2]&&t2);else if("ping"===t[0]){var n={gdprApplies:e,cmpLoaded:!1,cmpStatus:"stub"};"function"==typeof t[2]&&t2}else i.push(t)},o.addEventListener("message",function(i){var a="string"==typeof i.data,e={};try{e=a?JSON.parse(i.data):i.data}catch(e){}var o=e.__tcfapiCall;o&&window.__tcfapi(o.command,o.version,function(e,t){var n={__tcfapiReturn:{returnValue:e,success:t,callId:o.callId}};a&&(n=JSON.stringify(n)),i.source.postMessage(n,"*")},o.parameter)},!1))}();var a=function(){var e=arguments;typeof window.__uspapi!==a&&setTimeout(function(){void 0!==window.__uspapi&&window.__uspapi.apply(window.__uspapi,e)},500)};if(void 0===window.__uspapi){window.__uspapi=a;var o=setInterval(function(){i++,window.__uspapi===a&&i<3?console.warn("USP is not accessible"):clearInterval(o)},6e3)}}(),"function"==typeof window.__uspapi&&window.__uspapi("uspPing",1,function(e,t){t&&e.mode.includes("USP")&&e.jurisdiction.includes(e.location.toUpperCase())&&window.__uspapi("setUspDftData",1,function(e,t){t||console.log("Error: USP string not updated!")})})</script> If you're seeing this message, that means JavaScript has been disabled on your browser, please enable JS to make Imgur work.

<script class="abp" src="https://s.imgur.com/min/px.js?ch=1"></script> <script class="abp" src="https://s.imgur.com/min/px.js?ch=2"></script> <script>!function(e,t,n,o,c,a,f){e.fbq||(c=e.fbq=function(){c.callMethod?c.callMethod.apply(c,arguments):c.queue.push(arguments)},e._fbq||(e._fbq=c),(c.push=c).loaded=!0,c.version="2.0",c.queue=[],(a=t.createElement(n)).async=!0,a.src="//connect.facebook.net/en_US/fbevents.js",(f=t.getElementsByTagName(n)[0]).parentNode.insertBefore(a,f))}(window,document,"script"),fbq("init","742377892535530"),fbq("track","PageView"),"?reg"===document.location.search&&fbq("track","CompleteRegistration")</script>

<script src="https://s.imgur.com/desktop-assets/js/main.8864cd67e6ebb60dd112.js"></script>

Can you create a simple use case with a user that has only one image, that has been deleted, and triggers this issue? It would help testing / debugging.