riazXrazor / udemy-dl

Nodejs script to download a udemy.com course, for personal offline use
282 stars 67 forks source link

SyntaxError: Unexpected token u in JSON at position 0 #17

Closed abhion closed 6 years ago

abhion commented 6 years ago

I can download some courses. But some courses show this error. Select the video resolution to download: 480 undefined:1 undefined ^

SyntaxError: Unexpected token u in JSON at position 0 at Object.parse (native) at Request._callback (C:\Users\Abhi\AppData\Roaming\npm\node_modules\udemy-dl\lib\core.js:249:32) at self.callback (C:\Users\Abhi\AppData\Roaming\npm\node_modules\udemy-dl\node_modules\request\request.js:186:22) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at Request.onRequestError (C:\Users\Abhi\AppData\Roaming\npm\node_modules\udemy-dl\node_modules\request\request.js:878:8) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at TLSSocket.socketErrorListener (_http_client.js:310:9) at emitOne (events.js:96:13)

electather commented 6 years ago

same error for me @720 p

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (C:\Users\Administrator\AppData\Roaming\npm\node_module
s\udemy-dl\lib\core.js:249:32)
    at self.callback (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ud
emy-dl\node_modules\request\request.js:186:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (C:\Users\Administrator\AppData\Roaming\npm\node_m
odules\udemy-dl\node_modules\request\request.js:878:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
riazXrazor commented 6 years ago

Can you share the courses url plz, that would be helpful

electather commented 6 years ago

@riazXrazor sure thing. thanks for the app https://www.udemy.com/java-the-complete-java-developer-course/

abhion commented 6 years ago

Yeah. Thanks for making this. Here's the url: https://www.udemy.com/the-complete-guide-to-angular-2/learn/v4/overview

riazXrazor commented 6 years ago

just to make it clear, you bought the course right ?

abhion commented 6 years ago

yes, I bought it

electather commented 6 years ago

yeah. i did

riazXrazor commented 6 years ago

ok, thanks i'll do a debug and fix the bug :+1:

electather commented 6 years ago

thanks. @riazXrazor

abhion commented 6 years ago

cool. once again, thanks for making this

riazXrazor commented 6 years ago

guys,can you view the course at the respective resolution in the udemy site ?

electather commented 6 years ago

yeah. i'm watching it right now at 720

abhion commented 6 years ago

yeah I can

riazXrazor commented 6 years ago

can anyone help me debug, jst wat some info from you ?

electather commented 6 years ago

yeah sure. how can i help?

riazXrazor commented 6 years ago

udemy-debug

if any one of you know how to use the googledev tool plz can you send me the response for the highlited url,

riazXrazor commented 6 years ago

if ur having trouble, jst wait m making a small vid of how to do.

electather commented 6 years ago

that would be great! i did not find that url, bunch of others

riazXrazor commented 6 years ago

https://drive.google.com/file/d/1nMuifpk4LVQoGWYZsViyazKzJUOi9Cbp/view?usp=sharing

riazXrazor commented 6 years ago

if u hv any queries jst let me kno, i'll guide you

abhion commented 6 years ago

This is what I see in the response tab: {{"_class": "lecture", "id": 6655606, "title": "Project Setup and First App", "created": "2017-03-07T12:54:48Z", "description": "<p>Enough of the talking, let's create our first Angular project and view our first app in the browser.</p>", "title_cleaned": "project-setup-and-first-app", "is_published": true, "transcript": "", "is_downloadable": true, "is_free": true, "asset": {"_class": "asset", "id": 8854490, "asset_type": "Video", "title": "getting-started-04-setup-and-first-app.mp4", "created": "2017-07-01T08:22:20Z", "status": 1, "external_url": "", "download_urls": {"Video": [{"type": "video/mp4", "label": "720", "file": "https://udemy-assets-on-demand2.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/WebHD_720p.mp4?nva=20171209232856&filename=getting-started-04-setup-and-first-app.mp4&download=True&token=0c3ae0361be9c63fcac34"}, {"type": "video/mp4", "label": "480", "file": "https://udemy-assets-on-demand.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/WebHD_480.mp4?nva=20171209232856&filename=getting-started-04-setup-and-first-app.mp4&download=True&token=02e650f26ac11f9927666"}, {"type": "video/mp4", "label": "360", "file": "https://udemy-assets-on-demand2.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/WebHD.mp4?nva=20171209232856&filename=getting-started-04-setup-and-first-app.mp4&download=True&token=05870ac664c100fc2b14f"}, {"type": "video/mp4", "label": "144", "file": "https://udemy-assets-on-demand.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/Web_144.mp4?nva=20171209232856&filename=getting-started-04-setup-and-first-app.mp4&download=True&token=04f1627085d549fb14f54"}]}, "slide_urls": []}, "sort_order": 586, "course": {"_class": "course", "id": 756150, "url": "/the-complete-guide-to-angular-2/", "is_paid": true, "has_autogenerated_captions": true}, "view_html": "\n\n\n\n\n<div class=\"asset-container ud-angular-loader\"\n data-module-id=\"asset-player\"\n data-module-name=\"asset-player/app\">\n <react-video-player class=\"w100p h100p\"\n country-id=\"'None'\"\n download-api-url=\"'/api-2.0/users/me/subscribed-courses/756150/lectures/6655606'\"\n lecture-id=\"6655606\"\n asset-id=\"8854490\"\n course-id=\"756150\"\n on-video-available=\"onVideoAvailable\"\n on-video-end=\"onVideoEnd\"\n on-video-progress=\"onVideoProgress\"\n on-video-tracking=\"onVideoTracking\"\n player-id=\"'js-video-player_8854490_61306891'\"\n progress-event-name=\"'lectureProgress_6655606'\"\n thumbnail=\"'https://udemy-assets-on-demand.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/thumb-1.jpg?nva=20171209232856&amp;token=06c82cfcd035afb00c5ff'\"\n tracking-tag=\"'ctp_lecture'\"\n video-autofocus=\"true\"\n videojs-setup-data=\"{&quot;autoplay&quot;:true,&quot;playbackRates&quot;:[0.5,0.75,1,1.25,1.5,2.0],&quot;inactivityTimeout&quot;:800,&quot;flash&quot;:{&quot;hls&quot;:{&quot;withCredentials&quot;:true}},&quot;plugins&quot;:{&quot;bookmark&quot;:{},&quot;resolutionSelector&quot;:{&quot;defaultRes&quot;:&quot;Auto,720,480,360&quot;,&quot;extraLinks&quot;:[{&quot;event&quot;:&quot;downloadlecture&quot;,&quot;name&quot;:&quot;Download lecture&quot;},{&quot;event&quot;:&quot;showhotkeys&quot;,&quot;name&quot;:&quot;Keyboard shortcuts&quot;},{&quot;template&quot;:&quot;\\u003cspan\\u003eReport Technical Issue\\u003c/span\\u003e&quot;,&quot;event&quot;:&quot;reporttechnical&quot;,&quot;name&quot;:&quot;Report Technical Issue&quot;},{&quot;template&quot;:&quot;\\u003ci class=\\&quot;udi udi-flag mr5\\&quot;\\u003e\\u003c/i\\u003e\\u003cspan\\u003eReport Abuse\\u003c/span\\u003e&quot;,&quot;event&quot;:&quot;reportabuse&quot;,&quot;name&quot;:&quot;Report Abuse&quot;}]},&quot;speedcontroller&quot;:{},&quot;timer&quot;:{&quot;positionEventName&quot;:&quot;positionHandler_6655606&quot;,&quot;interval&quot;:15,&quot;progressEventName&quot;:&quot;lectureProgress_6655606&quot;},&quot;udemypatches&quot;:{&quot;inactiveTimeoutTime&quot;:2000},&quot;hotkeys&quot;:{&quot;enableMute&quot;:false}},&quot;controlBar&quot;:{&quot;volumeControl&quot;:false,&quot;captionsButton&quot;:{&quot;title&quot;:&quot;Captions&quot;},&quot;muteToggle&quot;:false,&quot;playbackRateMenuButton&quot;:false,&quot;progressControl&quot;:{&quot;seekBar&quot;:{&quot;mouseTimeDisplay&quot;:false},&quot;keepTooltipsInside&quot;:false},&quot;volumeMenuButton&quot;:{&quot;volumeBar&quot;:{&quot;vertical&quot;:true},&quot;inline&quot;:false}},&quot;sources&quot;:[{&quot;type&quot;:&quot;video/mp4&quot;,&quot;src&quot;:&quot;https://udemy-assets-on-demand2.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/WebHD_720p.mp4?nva=20171209232856\\u0026token=086ccf61d2fdafc596e3f&quot;,&quot;label&quot;:&quot;720&quot;},{&quot;type&quot;:&quot;video/mp4&quot;,&quot;src&quot;:&quot;https://udemy-assets-on-demand.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/WebHD_480.mp4?nva=20171209232856\\u0026token=0359699b2aa3dc1611db8&quot;,&quot;label&quot;:&quot;480&quot;},{&quot;type&quot;:&quot;video/mp4&quot;,&quot;src&quot;:&quot;https://udemy-assets-on-demand2.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/WebHD.mp4?nva=20171209232856\\u0026token=0062124be1dd1c2e7c5f0&quot;,&quot;label&quot;:&quot;360&quot;},{&quot;type&quot;:&quot;video/mp4&quot;,&quot;src&quot;:&quot;https://udemy-assets-on-demand.udemy.com/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/Web_144.mp4?nva=20171209232856\\u0026token=03ef886693f25844e1632&quot;,&quot;label&quot;:&quot;144&quot;},{&quot;type&quot;:&quot;application/x-mpegURL&quot;,&quot;src&quot;:&quot;HTTPS://adaptive-streaming.udemy.com/756150/8854490/2017-07-01_08-22-20-4ea27221a1186de98f53e8cbe3e8cf27/aa00bc77c6290d2f6f05cefb1f92d84a00bb.m3u8?nva=1512862136\\u0026ttl=16200\\u0026ip=None\\u0026token=09493af2598e0d36a25c4&quot;,&quot;label&quot;:&quot;Auto&quot;}],&quot;duration&quot;:313,&quot;html5&quot;:{&quot;hls&quot;:{&quot;withCredentials&quot;:true}}}\"\n text-tracks=\"[{&quot;label&quot;:&quot;English [Auto]&quot;,&quot;srclang&quot;:&quot;en&quot;,&quot;src&quot;:&quot;https://udemy-captions.s3.amazonaws.com:443/8854490/en_US/2017-07-10_15-37-29-5bb2c5066520402cdbf6571adf943aa1.vtt?Signature=Qbo97Ne%2FoU0czr2qM6yLJIa4WvU%3D\\u0026Expires=1512860336\\u0026AWSAccessKeyId=AKIAJA6MCXJVONCBES7A\\u0026response-content-disposition=attachment%3B%20filename%3D%22project-setup-and-first-appautogenerated.vtt%22&quot;,&quot;kind&quot;:&quot;captions&quot;,&quot;language&quot;:&quot;en&quot;}]\"\n player-skin=\"'vjs-udemy-skin-v2'\"\n player-config=\"'ct_v4'\"\n preload=\"'auto'\"\n >\n </react-video-player>\n</div>\n", "can_give_cc_feedback": true, "can_see_cc_feedback_popup": true}

riazXrazor commented 6 years ago

thanks a lot guys, i think i can debug with this :1st_place_medal:

riazXrazor commented 6 years ago

thanks @electather and @abhion :+1: now i can analyse and debug

electather commented 6 years ago

thanks man! so glad i could help

abhion commented 6 years ago

Are you working on this at 12.30 a.m

riazXrazor commented 6 years ago

:smiley: yup this problem seems quite interesting, trying to find the bug.

abhion commented 6 years ago

Awesome.. Good luck

riazXrazor commented 6 years ago

thanks man !! :smile:

riazXrazor commented 6 years ago

well i push out a small fix, not sure though if it will work or not, plz test and let me know weather the issue is fixed or not.

Thanks, Riaz

electather commented 6 years ago

great, thanks.

electather commented 6 years ago

now i'm getting this error

? Select the video resolution to download: 720
Error occured during getting lecture
{ Error: connect ETIMEDOUT 151.101.1.168:443
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '151.101.1.168',
  port: 443 }

any idea why?

ps. i'm working with windows server 2012 r2 and i think there is a conflict in port 443.

Using any web application with Work Folders may create port conflicts between the web application and Work Folders. Work Folders uses by default ports HTTPS=443 and HTTP=80. Most web applications use the same well known ports.

can you fix the port or recommend any way to resolve this conflict? it would be much appreciated

riazXrazor commented 6 years ago

It seems like a network error

On Sun 10 Dec, 2017, 2:36 AM electather, notifications@github.com wrote:

now i'm getting this error

? Select the video resolution to download: 720 Error occured during getting lecture { Error: connect ETIMEDOUT 151.101.1.168:443 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect', address: '151.101.1.168', port: 443 }

any idea why?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/riazXrazor/udemy-dl/issues/17#issuecomment-350505550, or mute the thread https://github.com/notifications/unsubscribe-auth/AMlUe2TTNeytUfv4bdcjlT3-UzpawZjWks5s-vZPgaJpZM4Q7dA1 .

electather commented 6 years ago

I know. There is a conflict with this app and windows server's default port (443) how can i change it?

abhion commented 6 years ago

Should I just do another npm install to install the new version?

riazXrazor commented 6 years ago

@abhion yup

abhion commented 6 years ago

I'm still getting the same error man

riazXrazor commented 6 years ago

@abhion then uninstall n install again.

riazXrazor commented 6 years ago

@electather can you try disabling the windows server ?

riazXrazor commented 6 years ago

@abhion btw i didn't find any issue with the code as to way the error is occurring so i put better error handling to get more precise error message.

electather commented 6 years ago

@riazXrazor i'm using a VPS for downloads ( some problems with my current ISP so i'm doing my huge downloads there then p2p to my pc) so i can't disable windows server

riazXrazor commented 6 years ago

in case of that, well m not sure try adding 151.101.1.168:443 to the incoming and outgoing connections TCP list if you have any , or the firewall exception list.

electather commented 6 years ago

@riazXrazor thanks. fixed now

riazXrazor commented 6 years ago

@electather your welcome :+1:

abhion commented 6 years ago

it works. thanks a lot man