Hypem Ruby Gem
Introduction
This is an unoffical Ruby gem for the Hype Machine read-only API. It currently only supports Ruby 1.9.x
.
Usage
Playlist
The Playlist
object is the root of the Hypem API. Each Playlist
has an array of Hypem::Track
's accessed via the tracks
attribute. Pagination is supported with the .next_page
and .prev_page
, page(num)
methods.
Querying
General playlists can be accessed using the following methods. The last argument to each method is the desired page (default 1
).
Hypem.playlist.artist('artist_name')
--- latest tracks from a given artistHypem.playlist.blog('blog_name')
--- latest tracks from a given blog nameHypem.playlist.search('query_string')
--- tracks matching stringHypem.playlist.tags(['tag_name','electro','indie'])
--- tracks matching tags. The API warns against combining too many different tagsHypem.playlist.popular
--- the most popular tracks over a certain timeframe or set. It accepts the following filters:'3day'
default --- most popular over last 3 days:lastweek
--- most popular over last week:noremix
--- most popular non-remixed tracks over last 3 days:artists
--- most popular artists' tracks over last 3 days:twitter
--- most popular tweeted tracks over last 3 days
Hypem.playlist.latest
--- the latest posted tracks. It accepts the following filters::all
default --- all tracks, regardless of repost status:fresh
--- only first posted tracks:noremix
--- only non-remixed tracks:remix
--- only remixed tracks
Misc.
Hypem.playlist.create_url([hypem_track1,hypem_track2])
--- create a custom Hypem-based playlist URL using array ofHypem::Track
's
User
Users can be accessed via Hypem.user('username')
and have various methods:
General Methods
user.get_profile
updates the user object with the following attributes:full_name
,location
,image_url
,followed_users_count
,followed_items_count
,followed_sites_blog
, andfollowed_queries_count
user.friends
retrieves the user's friends as an array ofHypem::User
objectsuser.favorite_blogs
retrieves the user's favorite blogs as an array ofHypem::Blog
objects
Playlist Methods
Hypem::User
offers several methods for accessing a particular user's personalized playlists:
user.loved_playlist
--- a user's loved tracksuser.obsessed_playlist
--- a user's obsessed tracksuser.feed_playlist
--- a user's tracks from all followed entitiesuser.friends_favorites_playlist
--- a user's friends' favorited tracksuser.friends_history_playlist
--- tracks from a user's friends' listening histories
Blog
Blogs can be retrieved using a blog's unique id via Hypem.blog(1234)
and have the following methods:
blog.get_info
-- retrieves extended information about a blog and setsblog_image
,blog_image_small
,first_posted
,followers
,last_posted
,site_name
,site_url
,total_tracks
, andid
Track
All Playlist objects have a tracks
attribute containing an array of Hypem::Track
's. A sample object inspect is as follows:
#<Hypem::Track
artist="Hot Chip"
date_loved=1332109580
date_posted=1332252311
description="O Hot Chip está de volta com um novo álbum, In Our Heads, que vai ser lançado oficialmente em junho, mas já conta com seu primeiro vídeo, “Flutes”, disponível para visualização. A faixa serve de abertura para o novo álbum dos já bem sucedidos garotos, e p"
itunes_link="http://hypem.com/go/itunes_search/Hot%20Chip"
loved_count=4912
media_id="1jsw9"
post_id=1753700
post_url="http://www.ohmyrock.net/2012/03/hot-chip-flutes/"
posted_count=14
site_id=14635
sitename="Oh My Rock"
thumb_url="http://static-ak.hypem.net/images/albumart4.gif"
thumb_url_large="http://static-ak.hypem.net/images/blog_images/14635.png"
time=425
title="Flutes">
TODO
- Blogs with given tag
- Single track info
- Authenticated Requests
- Favorite a track
- Log Playback