philippe_44 wrote:
> And for my understanding, what is the difference with dlmixcloud.com? Is
> this a download only site which would explain while streaming from it
> often fails?
>
> [edit]: forget the question, I looked online and at the code and I
> understand now. So *very* likely the stream fails b/c dlmixcloud is not
> made for streaming...
I don't think so, the streaming comes directly from Mixcloud dlmixcloud
has nothing to do with that,
The only thing it does (as far as I understand it) is decoding a file it
gets from mixcloud and getting the url out of it.
when looking at the code from the mixcloud for kodi it looks like its
decoding a json file.
Code:
--------------------
keysplit=cloudcast_key.split('/')
log_if_debug('keysplit[empty, username, slug, empty]=%s' % (keysplit))
# get crsf token
csrf_token=None
response=urllib2.urlopen(URL_MIXCLOUD)
headers=response.info()
for header in headers.getallmatchingheaders('Set-Cookie'):
cookie=header.split(': ',1)[1]
attributes=cookie.split('; ')
for attribute in attributes:
pair=attribute.split('=')
if pair[0]=='csrftoken':
csrf_token=pair[1]
log_if_debug('csrf_token=%s' % (csrf_token))
# create graphql
graphql={
'query' : 'query HeaderQuery(\n $lookup: CloudcastLookup!\n) {\n cloudcast:
cloudcastLookup(lookup: $lookup) {\n id\n isExclusive\n
...PlayButton_cloudcast\n }\n}\n\nfragment PlayButton_cloudcast on Cloudcast
{\n streamInfo {\n hlsUrl\n dashUrl\n url\n uuid\n }\n}\n',
'variables' : {
'lookup' : {
'username' : keysplit[1],
'slug' : keysplit[2]
}
}
}
log_if_debug('graphql=%s' % (graphql))
# request graphql
postdata=json.dumps(graphql)
headers={
'Referer' : URL_MIXCLOUD,
'X-CSRFToken' : csrf_token,
'Cookie' : 'csrftoken=' + csrf_token,
'Content-Type' : 'application/json'
}
request=urllib2.Request(URL_GRAPHQL, postdata, headers, URL_MIXCLOUD)
response=urllib2.urlopen(request)
content=response.read()
json_content=json.loads(content)
log_if_debug('response=%s' % (json_content))
# parse json
json_isexclusive=False
json_url=None
if STR_DATA in json_content and json_content[STR_DATA]:
json_data = json_content[STR_DATA]
if STR_CLOUDCAST in json_data and json_data[STR_CLOUDCAST]:
json_cloudcast = json_data[STR_CLOUDCAST]
if STR_ISEXCLUSIVE in json_cloudcast and json_cloudcast[STR_ISEXCLUSIVE]:
json_isexclusive = json_cloudcast[STR_ISEXCLUSIVE]
if STR_STREAMINFO in json_cloudcast and json_cloudcast[STR_STREAMINFO]:
json_streaminfo = json_cloudcast[STR_STREAMINFO]
if STR_URL in json_streaminfo and json_streaminfo[STR_URL]:
json_url = json_streaminfo[STR_URL]
elif STR_HLSURL in json_streaminfo and json_streaminfo[STR_HLSURL]:
json_url = json_streaminfo[STR_HLSURL]
elif STR_DASHURL in json_streaminfo and json_streaminfo[STR_DASHURL]:
json_url = json_streaminfo[STR_DASHURL]
if json_url:
log_if_debug('encoded url: '+json_url)
decoded_url=base64.b64decode(json_url)
url=''.join(chr(ord(a) ^ ord(b)) for a,b in
zip(decoded_url,cycle(STR_MAGICSTRING)))
log_if_debug('url: '+url)
return url
elif json_isexclusive:
log_if_debug('Cloudcast is exclusive')
return STR_ISEXCLUSIVE
else:
log_if_debug('Unable to find url in json')
--------------------
now I'm no coder but this looks like there is something encrypted.
with actually a good password :)
Code:
--------------------
STR_MAGICSTRING= u'IFYOUWANTTHEARTISTSTOGETPAIDDONOTDOWNLOADFROMMIXCLOUD'
--------------------
but it gets the stream directly from Mixcloud
cheers
Dennis
------------------------------------------------------------------------
cortegedusage's Profile: http://forums.slimdevices.com/member.php?userid=69028
View this thread: http://forums.slimdevices.com/showthread.php?t=88286
_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins