playlists/tasks.py
def send_track_to_live365(request):
    """
    Background Task URL to send playlist to Live 365 service.

    This view expects POST parameters:

    **id**
    The Datastore key of the playlist entry

    When POSTing to Live 365 here are the parameters:

    **member_name**
    Live365 member name

    **password**
    Live365 password

    **sessionid**
    Unused.  This is an alternative to user password and looks like
    membername:sessionkey as returned by api_login.cgi

    **version**
    Version of API request.  Currently this must be 2

    **filename**
    I think we can leave this blank because Live365 docs say they
    will use it to guess song and artist info if none was sent.

    **seconds**
    Length of the track in seconds.  Live365 uses this to refresh its
    popup player window thing.  So really we should probably set this to 60 or 120
    because DJs might be submitting playlist entries out of sync with when
    they are actually playing the songs.

    **title**
    Song title

    **artist**
    Artist name

    **album**
    Album title
    """
    track = AutoRetry(PlaylistEvent).get(request.POST['id'])
    if not track:
        log.warning("Requested to create a non-existant track of ID %r" % request.POST['id'])
        # this is not an error (malicious POST, etc), so make sure the task succeeds:
        return task_response({'success':True})

    log.info("Live365 create track %s" % track.key())

    qs = {
        'member_name': dbconfig['live365.member_name'],
        'password': dbconfig['live365.password'],
        'version': 2,
        'seconds': 30,
        'title': as_encoded_str(track.track_title, encoding='latin-1', errors="ignore"),
        'artist': as_encoded_str(track.artist_name, encoding='latin-1', errors="ignore"),
        'album': as_encoded_str(track.album_title, encoding='latin-1', errors="ignore")
    }
    data = urllib.urlencode(qs)
    headers = {"Content-type": "application/x-www-form-urlencoded"}
    # in prod: http://www.live365.com/cgi-bin/add_song.cgi
    service_url = dbconfig['live365.service_url']
    result = _fetch_url(url=service_url, method='POST', data=data, headers=headers)
    return task_response(result)

    Background Task URL to send playlist to Live 365 service.

    This view expects POST parameters:

    **id**
    The Datastore key of the playlist entry

    When POSTing to Live 365 here are the parameters:

    **member_name**
    Live365 member name

    **password**
    Live365 password

    **sessionid**
    Unused.  This is an alternative to user password and looks like
    membername:sessionkey as returned by api_login.cgi

    **version**
    Version of API request.  Currently this must be 2

    **filename**
    I think we can leave this blank because Live365 docs say they
    will use it to guess song and artist info if none was sent.

    **seconds**
    Length of the track in seconds.  Live365 uses this to refresh its
    popup player window thing.  So really we should probably set this to 60 or 120
    because DJs might be submitting playlist entries out of sync with when
    they are actually playing the songs.

    **title**
    Song title

    **artist**
    Artist name

    **album**
    Album title
    
Background Task URL to send playlist to Live 365 service.
This view expects POST parameters.

id
The Datastore key of the playlist entry

When POSTing to Live 365 here are the parameters.

member_name
Live365 member name

password
Live365 password

sessionid
Unused.  This is an alternative to user password and looks like
membername:sessionkey as returned by api_login.cgi

version
Version of API request.  Currently this must be 2

filename
I think we can leave this blank because Live365 docs say they
will use it to guess song and artist info if none was sent.

seconds
Length of the track in seconds.  Live365 uses this to refresh its
popup player window thing.  So really we should probably set this to 60 or 120
because DJs might be submitting playlist entries out of sync with when
they are actually playing the songs.

title
Song title

artist
Artist name

album
Album title
Background Task URL to send playlist to Live 365 service . This view expects POST parameters . id The Datastore key of the playlist entry When POSTing to Live 365 here are the parameters . member_name Live365 member name password Live365 password sessionid Unused . This is an alternative to user password and looks like membername : sessionkey as returned by api_login . cgi version Version of API request . Currently this must be 2 filename I think we can leave this blank because Live365 docs say they will use it to guess song and artist info if none was sent . seconds Length of the track in seconds . Live365 uses this to refresh its popup player window thing . So really we should probably set this to 60 or 120 because DJs might be submitting playlist entries out of sync with when they are actually playing the songs . title Song title artist Artist name album Album title
def send_track_to_live365(request):
    track = AutoRetry(PlaylistEvent).get(request.POST['id'])
    if not track:
        log.warning("Requested to create a non-existant track of ID %r" % request.POST['id'])
        return task_response({'success':True})
    log.info("Live365 create track %s" % track.key())
    qs = {
        'member_name': dbconfig['live365.member_name'],
        'password': dbconfig['live365.password'],
        'version': 2,
        'seconds': 30,
        'title': as_encoded_str(track.track_title, encoding='latin-1', errors="ignore"),
        'artist': as_encoded_str(track.artist_name, encoding='latin-1', errors="ignore"),
        'album': as_encoded_str(track.album_title, encoding='latin-1', errors="ignore")
    }
    data = urllib.urlencode(qs)
    headers = {"Content-type": "application/x-www-form-urlencoded"}
    service_url = dbconfig['live365.service_url']
    result = _fetch_url(url=service_url, method='POST', data=data, headers=headers)
    return task_response(result)
def send_track_to_live365 ( request ) : track = AutoRetry ( PlaylistEvent ) . get ( request . POST [ 'id' ] ) if not track : log . warning ( "Requested to create a non-existant track of ID %r" % request . POST [ 'id' ] ) return task_response ( { 'success' : True } ) log . info ( "Live365 create track %s" % track . key ( ) ) qs = { 'member_name' : dbconfig [ 'live365.member_name' ] , 'password' : dbconfig [ 'live365.password' ] , 'version' : 2 , 'seconds' : 30 , 'title' : as_encoded_str ( track . track_title , encoding = 'latin-1' , errors = "ignore" ) , 'artist' : as_encoded_str ( track . artist_name , encoding = 'latin-1' , errors = "ignore" ) , 'album' : as_encoded_str ( track . album_title , encoding = 'latin-1' , errors = "ignore" ) } data = urllib . urlencode ( qs ) headers = { "Content-type" : "application/x-www-form-urlencoded" } service_url = dbconfig [ 'live365.service_url' ] result = _fetch_url ( url = service_url , method = 'POST' , data = data , headers = headers ) return task_response ( result )
Background Task URL to send playlist to Live 365 service.
Background Task URL to send playlist to Live 365 service .
"""
    Background Task URL to send playlist to Live 365 service.

    This view expects POST parameters:

    **id**
    The Datastore key of the playlist entry

    When POSTing to Live 365 here are the parameters:

    **member_name**
    Live365 member name

    **password**
    Live365 password

    **sessionid**
    Unused.  This is an alternative to user password and looks like
    membername:sessionkey as returned by api_login.cgi

    **version**
    Version of API request.  Currently this must be 2

    **filename**
    I think we can leave this blank because Live365 docs say they
    will use it to guess song and artist info if none was sent.

    **seconds**
    Length of the track in seconds.  Live365 uses this to refresh its
    popup player window thing.  So really we should probably set this to 60 or 120
    because DJs might be submitting playlist entries out of sync with when
    they are actually playing the songs.

    **title**
    Song title

    **artist**
    Artist name

    **album**
    Album title
    """ # this is not an error (malicious POST, etc), so make sure the task succeeds: # in prod: http://www.live365.com/cgi-bin/add_song.cgi
request