annotate Yading/7digital-python/README @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 8c29444cb5fd
children
rev   line source
yading@7 1 7 digital API access via python | http://developer.7digital.net/
yading@7 2
yading@7 3 =======
yading@7 4 Download python code: http://github.com/ocelma/7-digital/downloads
yading@7 5
yading@7 6 Using the 7digital developer platform you can:
yading@7 7 * Build digital music applications for the web, desktop and mobile devices
yading@7 8 * Generate revenue with your own branded music download store
yading@7 9 * Access our catalogue of over 10,000,000 MP3 music tracks
yading@7 10 * Create your own streaming radio service
yading@7 11 * Include official sleeve artwork and audio samples
yading@7 12 * Have access to major labels licensed content in 16 major territories included US, Canada, UK, Germany, France, Spain, Italy and many more
yading@7 13
yading@7 14 See some usage examples here: http://github.com/ocelma/7-digital/tree/v1.0
yading@7 15
yading@7 16 DOWNLOAD LATEST VERSION: http://github.com/ocelma/7-digital/downloads
yading@7 17
yading@7 18 - Examples:
yading@7 19
yading@7 20 # If you want to use the cache, you have to manually create that dir (e.g. $ mkdir ./cache)
yading@7 21 import py7digital
yading@7 22
yading@7 23 #Search artist
yading@7 24 results = py7digital.search_artist('stones')
yading@7 25 print results.get_total_result_count()
yading@7 26 for artist in results.get_next_page():
yading@7 27 print artist.get_name() #, artist.get_image(), artist.get_url(), artist.get_tags()
yading@7 28 print '\tTop tracks:'
yading@7 29 for top_track in artist.get_top_tracks():
yading@7 30 print '\t\t', top_track.get_title(), top_track.get_isrc(), top_track.get_duration(), top_track.get_position(), top_track.get_explicit(), top_track.get_version()
yading@7 31 print '\tRec. Albums:'
yading@7 32 for rec_album in artist.get_recommended_albums():
yading@7 33 print '\t\t', rec_album, rec_album.get_year() #, album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label()
yading@7 34 for album in artist.get_albums(5):
yading@7 35 print '\t', album, album.get_year(), album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label(), album.get_release_date(), album.get_added_date()
yading@7 36 for sim_album in album.get_similar():
yading@7 37 print '\t\tSimilar:', sim_album, sim_album.get_year(), sim_album.get_artist()
yading@7 38 for track in album.get_tracks():
yading@7 39 print '\t\t', track, track.get_isrc() #, track.get_url(), track.get_audio()
yading@7 40
yading@7 41 #Browse artists starting with 'J'
yading@7 42 results = py7digital.browse_artists('j')
yading@7 43 print results.get_total_result_count()
yading@7 44 for artist in results.get_next_page():
yading@7 45 print artist.get_name() #, artist.get_image(), artist.get_url(), artist.get_tags()
yading@7 46 for album in artist.get_albums(2):
yading@7 47 print '\t', album, album.get_year() #album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label()
yading@7 48 for track in album.get_tracks():
yading@7 49 print '\t\t', track.get_title(), track.get_isrc() #, track.get_url(), track.get_audio()
yading@7 50
yading@7 51 #Search albums
yading@7 52 searcher = py7digital.search_album('u2')
yading@7 53 print searcher.get_total_result_count()
yading@7 54 while searcher.has_results():
yading@7 55 for album in searcher.get_next_page():
yading@7 56 print album, album.get_similar()
yading@7 57
yading@7 58 #Search tracks
yading@7 59 searcher = py7digital.search_track('u2 one')
yading@7 60 print searcher.get_total_result_count()
yading@7 61 while searcher.has_results():
yading@7 62 for track in searcher.get_next_page():
yading@7 63 print track
yading@7 64
yading@7 65 # New releases in a given period of time
yading@7 66 results = py7digital.album_releases('20100901', '20100924')
yading@7 67 for album in results.get_next_page():
yading@7 68 print album, album.get_year(), album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label(), album.get_release_date(), album.get_added_date()
yading@7 69 for sim_album in album.get_similar():
yading@7 70 print '\tSimilar:', sim_album, sim_album.get_year(), sim_album.get_artist()
yading@7 71 for track in album.get_tracks():
yading@7 72 print '\t', track, track.get_isrc() #, track.get_url(), track.get_audio()
yading@7 73
yading@7 74 # Album charts in a given period of time
yading@7 75 results = py7digital.album_charts('month', '20100901')
yading@7 76 for album in results.get_next_page():
yading@7 77 print album, album.get_year(), album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label(), album.get_release_date(), album.get_added_date()
yading@7 78 for sim_album in album.get_similar():
yading@7 79 print '\tSimilar:', sim_album, sim_album.get_year(), sim_album.get_artist()
yading@7 80 for track in album.get_tracks():
yading@7 81 print '\t', track, track.get_isrc() #, track.get_url(), track.get_audio()
yading@7 82
yading@7 83
yading@7 84 -- OAuth Usage
yading@7 85
yading@7 86 auth = Oauth7digital(CONSUMER_KEY, CONSUMER_SECRET)
yading@7 87 token = auth.request_token()
yading@7 88 authorized = auth.authorize_request_token(token)
yading@7 89 access_token = auth.request_access_token(token)
yading@7 90
yading@7 91 sevendigital = Oauth7digital(CONSUMER_KEY, CONSUMER_SECRET, access_token)
yading@7 92 results = sevendigital.get_locker()