Skip to content

Instantly share code, notes, and snippets.

@psykidellic
Created March 3, 2014 07:07
Show Gist options
  • Save psykidellic/9319820 to your computer and use it in GitHub Desktop.
Save psykidellic/9319820 to your computer and use it in GitHub Desktop.
find: (type, str, callback) -> # find == search?!
if type == 'playlists'
- @fetchVideosFromPlaylist("#{str}?v=2", callback)
+ @fetchPlaylist(str, callback)
else
- @search(str, callback)
+ @find_by_id(str, callback)
+ # else
+ # @search(str, callback)
find_by_url: (url, callback) ->
id = @_extract_youtube_id(url)
@@ -86,10 +88,26 @@ define (require) ->
callback(playlists)
)
+ fetchPlaylist: (uri, callback) ->
+ youtube_base_url = 'http://gdata.youtube.com/feeds/api/playlists'
+ params = { alt: 'json', v: '2' }
+ # RN: the "?" is important
+ url = "#{youtube_base_url}/#{uri}?&#{$.param params}"
+
+ console.log("Fetch videos from playlist #{url}")
+
+ # $.get(url)
+ # .done((data) ->
+ # console.log data
+
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment