danguilherme / spotivy

:musical_score: Download music videos from Spotify playlists
https://danguilherme.github.io/blog/spotivy
MIT License
85 stars 11 forks source link

App crashes if video was not found on YouTube #9

Closed MuadDib81 closed 6 years ago

MuadDib81 commented 6 years ago

If a video is not found on youtube, I would await to skip this one and go to the next, but it throws an error and quits. I don't know if this is intended or just a bug.

Output: ... [Downloading track] Maulisé - Une Beat Encore TypeError: Cannot read property 'snippet' of undefined at searchVideo.then.results (/usr/lib/node_modules/spotivy/youtube_search.js:60:65) at at process._tickCallback (internal/process/next_tick.js:188:7) [Download failed] Video not found

danguilherme commented 6 years ago

It's probably a bug.

Could you post the full output with the --verbose flag on?

MuadDib81 commented 6 years ago
[spotivy v0.4.3]
                  [DEBUG] Loaded options:
 {
  "spotifyClientId": "XXX",
  "spotifyClientSecret": "XXX",
  "youtubeKey": "XXX",
  "output": "/home/muaddib/test/media",
  "format": "video",
  "quality": "highest",
  "flat": false,
  "audio": false,
  "username": "Bostjan Bele",
  "playlists": [
    "37i9dQZF1DWTvNyxOwkztu"
  ]
}
Saving media to '/home/muaddib/test/media'

                  [DEBUG] Spotify login
   [Downloading playlist] Chillout Lounge
                  [DEBUG] Fetching playlist tracks (37i9dQZF1DWTvNyxOwkztu)
                  [DEBUG] Fetch paginated: "getPlaylistTracks"
                  [DEBUG] Fetch paginated: loading 0..20
                  [DEBUG] Fetch paginated: loaded  20/80
                  [DEBUG] Fetch paginated: pushing down the stream
                  [DEBUG] Fetch paginated: next page
                  [DEBUG] Fetch paginated: loading 20..40
                  [DEBUG] Fetch paginated: loaded  40/80
                  [DEBUG] Fetch paginated: pushing down the stream
      [Downloading track] Maulisé - Une Beat Encore
                  [DEBUG] Search video: search "Maulisé - Une Beat Encore"
                  [DEBUG] Fetch paginated: next page
                  [DEBUG] Search video: 0 item(s) returned
                  [DEBUG] Search music video: None of the videos is considered a good result
TypeError: Cannot read property 'snippet' of undefined
    at searchVideo.then.results (/usr/lib/node_modules/spotivy/youtube_search.js:60:65)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
        [Download failed] Video not found
                  [DEBUG] Error: Video not found
    at Stream.highland [as _generator] (/usr/lib/node_modules/spotivy/index.js:295:14)
    at Stream._runGenerator (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1343:10)
    at Stream._resume (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1178:22)
    at Stream._checkBackPressure (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1091:10)
    at Stream._resume (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1172:33)
    at Stream.resume (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1205:10)
    at Stream.pull (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1596:7)
    at Stream._generator (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:3503:14)
    at Stream._runGenerator (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1343:10)
    at Stream._resume (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1178:22)
    at Stream._generator_next (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:786:22)
    at /usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:3524:21
    at /usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1593:9
    at Stream.s._send (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1549:9)
    at Stream.write (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:1650:18)
    at Stream._send (/usr/lib/node_modules/spotivy/node_modules/highland/lib/index.js:974:26)
lnfnunes commented 6 years ago

@MuadDib81 What command did you run to get this error? I tried spotivy playlist spotify 37i9dQZF1DWTvNyxOwkztu and everything works fine!

MuadDib81 commented 6 years ago

the command I used was spotivy playlist "Bostjan Bele" 37i9dQZF1DWTvNyxOwkztu -a

danguilherme commented 6 years ago

Issue fix landed in v0.4.4.

Thanks @MuadDib81 for reporting and @lnfnunes for fixing!