OZ Radio Streaming Plugin Code

Hi Everyone,
 
Thought I would share a plugin I put together to stream ozzie radio stations. The code is the framework of which you would need to locate your own streams and insert it into the relevant sections of the code. its based on the shoutcast plugin. you should have some familiarisation with creating bundles before using this code as there is no real support if you cannot get things working.
 
Hope its helpful to some of you.

 

Cheers

Diego

ART = 'art-default.jpg'
ICON = 'icon-default.jpg'

####################################################################################################
def Start():

ObjectContainer.art = R(ART)
ObjectContainer.title1 = 'OZ Radio'
TrackObject.thumb = R(ICON)

####################################################################################################
@handler(’/music/ozradio’, ‘OZ Radio’, thumb=ICON, art=ART)
def MainMenu():

oc = ObjectContainer()
oc.add(CreateTrackObject(url='http://117.53.175.113:15014/', title='Nova 96.9 FM', fmt='aac'))
oc.add(CreateTrackObject(url='http://shoutcast.2gb.com:80/', title='2GB 873', fmt='mp3'))

return oc

####################################################################################################
def CreateTrackObject(url, title, fmt, include_container=False):

if fmt == 'mp3':
	container = Container.MP3
	audio_codec = AudioCodec.MP3
elif fmt == 'aac':
	container = Container.MP4
	audio_codec = AudioCodec.AAC

track_object = TrackObject(
	key = Callback(CreateTrackObject, url=url, title=title, fmt=fmt, include_container=True),
	rating_key = url,
	title = title,
	items = [
		MediaObject(
			parts = [
				PartObject(key=Callback(PlayAudio, url=url, ext=fmt))
			],
			container = container,
			audio_codec = audio_codec,
			audio_channels = 2
		)
	]
)

if include_container:
	return ObjectContainer(objects=[track_object])
else:
	return track_object

####################################################################################################
def PlayAudio(url):

return Redirect(url)

DeigoV,

Thank you for posting the code for streaming audio.  I was able to use your code to stream the free version of Whisperings, http://www.solopianoradio.com/

Plugin posted here: https://forums.plexapp.com/index.php/topic/87965-create-plugin-streaming-audio/?p=510479 

Thanks for sharing this.  I got it to work with a few stations.  One thing I noticed is it usually takes about 20 seconds for the stream to start.  Any ideas how this could be improved?

Here's some logs, including a bunch of warnings I don't entirely understand (yet)

2014-06-12 18:25:31,418 (47d0) :  DEBUG (runtime:717) - Handling request GET /music/ozradio
2014-06-12 18:25:31,423 (25e8) :  DEBUG (runtime:717) - Handling request GET /music/ozradio
2014-06-12 18:25:31,428 (47d0) :  DEBUG (runtime:814) - Found route matching /music/ozradio
2014-06-12 18:25:31,430 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,430 (25e8) :  DEBUG (runtime:814) - Found route matching /music/ozradio
2014-06-12 18:25:31,433 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,433 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,436 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,437 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,440 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,440 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,443 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,444 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,446 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,447 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,450 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,450 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,453 (47d0) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,453 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,456 (25e8) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:31,457 (47d0) :  DEBUG (base:123) - Checking if com.plexapp.plugins.OzRadio is broken
2014-06-12 18:25:31,460 (25e8) :  DEBUG (base:123) - Checking if com.plexapp.plugins.OzRadio is broken
2014-06-12 18:25:31,460 (47d0) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCcm9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMjcKY29tLnBsZXhhcHAucGx1Z2lucy5PelJhZGlvczEwCmlkZW50aWZpZXJyMAo_'
2014-06-12 18:25:31,463 (25e8) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCcm9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMjcKY29tLnBsZXhhcHAucGx1Z2lucy5PelJhZGlvczEwCmlkZW50aWZpZXJyMAo_'
2014-06-12 18:25:31,492 (47d0) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-06-12 18:25:31,493 (47d0) :  DEBUG (runtime:918) - Response: [200] MediaContainer, 3743 bytes
2014-06-12 18:25:31,496 (25e8) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-06-12 18:25:31,496 (25e8) :  DEBUG (runtime:918) - Response: [200] MediaContainer, 3743 bytes
2014-06-12 18:25:36,763 (3468) :  DEBUG (runtime:717) - Handling request GET /music/ozradio/:/function/PlayAudio.mp3?function_args=Y2VyZWFsMQoxCmRpY3QKMQpzMzUKaHR0cDovL3Nob3V0bWVkaWEuYWJjLm5ldC5hdToxMDQzNi9zMwp1cmxyMAo_
2014-06-12 18:25:36,766 (3468) :  DEBUG (runtime:814) - Found route matching /music/ozradio/:/function/PlayAudio.mp3
2014-06-12 18:25:36,767 (3468) :  DEBUG (runtime:143) - Calling function 'PlayAudio.mp3'
2014-06-12 18:25:36,769 (3468) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-06-12 18:25:36,769 (3468) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-06-12 18:25:37,286 (3c38) :  DEBUG (runtime:717) - Handling request GET /music/ozradio/:/function/PlayAudio.mp3?function_args=Y2VyZWFsMQoxCmRpY3QKMQpzMzUKaHR0cDovL3Nob3V0bWVkaWEuYWJjLm5ldC5hdToxMDQzNi9zMwp1cmxyMAo_
2014-06-12 18:25:37,290 (3c38) :  DEBUG (runtime:814) - Found route matching /music/ozradio/:/function/PlayAudio.mp3
2014-06-12 18:25:37,292 (3c38) :  DEBUG (runtime:143) - Calling function 'PlayAudio.mp3'
2014-06-12 18:25:37,293 (3c38) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-06-12 18:25:37,293 (3c38) :  DEBUG (runtime:918) - Response: [302] Redirect, 0 bytes
2014-06-12 18:25:48,867 (3698) :  DEBUG (runtime:717) - Handling request GET /music/ozradio/:/function/CreateTrackObject?function_args=Y2VyZWFsMQoxCmRpY3QKNApzMzUKaHR0cDovL3Nob3V0bWVkaWEuYWJjLm5ldC5hdToxMDQzNi9zMwp1cmxzMwptcDNzMwpmbXRiMXMxNwppbmNsdWRlX2NvbnRhaW5lcnM3CkFCQyA3MDJzNQp0aXRsZXIwCg__
2014-06-12 18:25:48,871 (3698) :  DEBUG (runtime:814) - Found route matching /music/ozradio/:/function/CreateTrackObject
2014-06-12 18:25:48,871 (3698) :  DEBUG (runtime:143) - Calling function 'CreateTrackObject'
2014-06-12 18:25:48,871 (3698) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:48,872 (3698) :  WARNING (runtime:1059) - Generating a callback path for a function with no route: 
2014-06-12 18:25:48,878 (3698) :  DEBUG (runtime:106) - Sending packed state data (108 bytes)
2014-06-12 18:25:48,880 (3698) :  DEBUG (runtime:918) - Response: [200] MediaContainer, 1227 bytes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.