New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON format option for playlist_videos #8

Merged
merged 2 commits into from Jun 20, 2014

Conversation

Projects
None yet
2 participants
@effektz
Contributor

effektz commented Jun 17, 2014

No description provided.

@@ -19,10 +19,14 @@ def search_playlists(query, options={})
search_page("https://gdata.youtube.com/feeds/api/playlists/snippets", query, options.merge(:v => 2))
end
def playlist_videos(playlist_id)
def playlist_videos(playlist_id, format='xml')

This comment has been minimized.

@grosser

grosser Jun 17, 2014

Owner

please use an options hash and add a test :)

This comment has been minimized.

@effektz

effektz Jun 20, 2014

Contributor

done :)

if format == 'xml'
parse(res, :type => :playlist)
else
res

This comment has been minimized.

@grosser

grosser Jun 17, 2014

Owner

might as well parse the json ?

This comment has been minimized.

@effektz

effektz Jun 20, 2014

Contributor

Since the parse method is setup to accept XML, passing JSON into parse actually destroys the formatting

playlist_id = playlist_id.sub(/^PL/, "")
xml = open("http://gdata.youtube.com/feeds/api/playlists/#{playlist_id}?v=2").read
parse(xml, :type => :playlist)
res = open("http://gdata.youtube.com/feeds/api/playlists/#{playlist_id}?v=2#{'&alt=json' if format == 'json'}").read

This comment has been minimized.

@grosser

grosser Jun 17, 2014

Owner

does sending alt=xml work <-> could get rid of an if

This comment has been minimized.

@effektz

effektz Jun 20, 2014

Contributor

Unfortunately sending alt=xml does not work

grosser added a commit that referenced this pull request Jun 20, 2014

Merge pull request #8 from effektz/master
Add JSON format option for playlist_videos

@grosser grosser merged commit bc61748 into grosser:master Jun 20, 2014

1 check failed

continuous-integration/travis-ci The Travis CI build failed
Details
@grosser

This comment has been minimized.

Owner

grosser commented Jun 20, 2014

0.1.8 is all yours :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment