Beispiel #1
0
def init_client(HttpMock):
    expiry = datetime.datetime.now()
    expiry += datetime.timedelta(hours=22)  # offset for HM timezone
    test_token = get_random_md5()

    return_values = [
         (200, """<?xml version="1.0" encoding="utf-8"?>
            <responseservicetoken>
                <token value="%s" expiry="%s"/>
            </responseservicetoken>""" % \
            (test_token, expiry.strftime("%Y-%m-%dT%H:%M:%S"))),
         (200, """<?xml version="1.0" encoding="utf-8"?>
            <responseserviceinfo>
                <asseturl
                    albumart="http://asset.harvestmedia.net/albumart/8185d768cd8fcaa7/{id}/{width}/{height}"
                    waveform="http://asset.harvestmedia.net/waveform/8185d768cd8fcaa7/{id}/{width}/{height}"
                    trackstream="http://asset.harvestmedia.net/trackstream/8185d768cd8fcaa7/{memberaccountid}/{id}"
                    trackdownload=" http://asset.harvestmedia.net/trackdownload/8185d768cd8fcaa7/{memberaccountid}/{id}/{trackformat}"
                    playlistdownload="http://download.harvestmedia.net/wsplaylistdownload/8185d768cd8fcaa7/{memberaccountid}/{id}/{trackformat}" 
                    playlistart="http://download.harvestmedia.net/wsplaylistart/8185d768cd8fcaa7/{id}/{width}/{height}" 
                    librarylogo="http://download.harvestmedia.net/wslibrarylogo/8185d768cd8fcaa7/{id}/{width}/{height}" />
                <trackformats>
                  <trackformat identifier="8185d768cd8fcaa7" extension="mp3" bitrate="320" samplerate="48" samplesize="16" />
                  <trackformat identifier="768cd8fcaa8185d7" extension="wav" bitrate="1536" samplerate="48" samplesize="16" />
                  <trackformat identifier="7jsi8fcaa818df57" extension="aif" bitrate="1536" samplerate="48" samplesize="16" />
                </trackformats>
            </responseserviceinfo>"""),
    ]

    http = build_http_mock(HttpMock, responses=return_values)
    api_key = '1234567'
    client = Client(api_key=api_key, debug_level='DEBUG')
    return client
Beispiel #2
0
from harvestmedia.api.config import Config
from harvestmedia.api.client import Client
from harvestmedia.api.member import Member
from harvestmedia.api.track import Track

api_key = 'e1d5d645d2d984e499e816a7a314dfbd610149f124c3373455c37ad75ab3ffccf444a04a10953b62'
webservice_url = 'https://service.harvestmedia.net/HMP-WS.svc'

client = Client(api_key=api_key, debug_level='DEBUG')

member = Member.query.get_by_id('46d6bb0b1a2aafe7', client)
favourites = member.get_favourites()

print favourites