I created a ServiceInfo.plist file in my plu-in bundle Content/Services directory. It looks like this:
<?xml version="1.0" encoding="UTF-8"?>
URL
ORF TVThek
TestURLs
http://tvthek.orf.at/programs/1379-Sport-Bild/episodes/6855679-Sport-Bild
http://tvthek.orf.at/topics/Fu%C3%9Fball/6886675-Sport-Aktuell/segments/6886697-OeFB-Team-in-Schweden
<key>URLPatterns</key>
<array>
<string>^http://tvthek.orf.at/(programs|topics).*?</string>
</array>
</dict>
</dict>
In the Content/Services/URL/ORF TVThek/ directory in my bundle I created a ServiceCode.pys file that looks like this:
RE_PLAYLIST = Regex("\'playlist\': *\'\[(.*)\]\'")
####################################################################################################
def MetadataObjectForURL(url):
# FILL IN
pass
####################################################################################################
def MediaObjectsForURL(url):
return [
MediaObject(
audio_channels = 2,
optimized_for_streaming = True,
parts = [
PartObject(
key = HTTPLiveStreamURL(Callback(PlayVideo, url = url))
)
]
)
]
####################################################################################################
def PlayVideo(url):
content = HTTP.Request(url).content
playListString = RE_PLAYLIST.search(content).groups()[0].replace('\\\"', '"')
playList = JSON.ObjectFromString(playListString)
return Redirect(playList['sources']['4_apple_Q4A']['src'])
it's essentially a cut and paste of meo's code above - I just changed the "'" to '"' in the .replace to get a valid JSON object, which then looks like this (for one of the test URLs):
{
"id":6892023,
"title":"Otto Waalkes im Anflug",
"sources":{
"0_android_Q1A":{
"src":"rtsp:\/\/apasfw.apa.at:1935\/cms-worldwide\/mp4:2013-10-11_1730_tl_02_heute-leben_Otto-Waalkes-im-Anfl__6891999__o__0000868857__s6892023___g__ORF2HiRes_18135616P_18191000P_Q1A.3gp",
"quality_string":"niedrig",
"quality_pattern":"Q1A"
},
"1_android_Q4A":{
"src":"rtsp:\/\/apasfw.apa.at:1935\/cms-worldwide\/mp4:2013-10-11_1730_tl_02_heute-leben_Otto-Waalkes-im-Anfl__6891999__o__0000868857__s6892023___g__ORF2HiRes_18135616P_18191000P_Q4A.mp4",
"quality_string":"mittel",
"quality_pattern":"Q4A"
},
"2_android_SMIL":{
"src":"rtsp:\/\/apasfw.apa.at:1935\/cms-worldwide\/mp4:2013-10-11_1730_tl_02_heute-leben_Otto-Waalkes-im-Anfl__6891999__o__0000868857__s6892023___g__ORF2HiRes_18135616P_18191000P_Q4A.mp4",
"quality_string":"hoch",
"quality_pattern":"SMIL"
},
"3_apple_Q1A":{
"src":"http:\/\/apasfiis.apa.at\/ipad\/cms-worldwide\/2013-10-11_1730_tl_02_heute-leben_Otto-Waalkes-im-Anfl__6891999__o__0000868857__s6892023___g__ORF2HiRes_18135616P_18191000P_Q1A.3gp\/playlist.m3u8",
"quality_string":"niedrig",
"quality_pattern":"Q1A",
"type":"video\/3gpp; codecs=\"avc1.42E01E, mp4a.40.2\""
},
"4_apple_Q4A":{
"src":"http:\/\/apasfiis.apa.at\/ipad\/cms-worldwide\/2013-10-11_1730_tl_02_heute-leben_Otto-Waalkes-im-Anfl__6891999__o__0000868857__s6892023___g__ORF2HiRes_18135616P_18191000P_Q4A.mp4\/playlist.m3u8",
"quality_string":"mittel",
"quality_pattern":"Q4A",
"type":"video\/mp4; codecs=\"avc1.42E01E, mp4a.40.2\""
},
"5_apple_SMIL":{
"src":"http:\/\/apasfw.apa.at:1935\/cms-worldwide\/smil:2013-10-11_1730_tl_02_heute-leben_Otto-Waalkes-im-Anfl__6891999__o__0000868857__s6892023___g__ORF2HiRes_18135616P_18191000P.smil\/playlist.m3u8",
"quality_string":"hoch",
"quality_pattern":"SMIL",
"type":"video\/mp4; codecs=\"avc1.42E01E, mp4a.40.2\""
}
}
}
When I try to run one of my test files against the Plex URL Services lookup (http://localhost:32400/system/services/url/lookup?url=) it returns a blank screen, and in the com.plexapp.system.log, I see:
2013-10-11 12:04:08,870 (-4fa6b000) : DEBUG (runtime:717) - Handling request GET /system/services/url/lookup?url=http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug
2013-10-11 12:04:08,938 (-4fa6b000) : DEBUG (runtime:814) - Found route matching /system/services/url/lookup
2013-10-11 12:04:08,938 (-4fa6b000) : DEBUG (services:23) - Looking up URL 'http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:08,939 (-4fa6b000) : DEBUG (services:615) - Found a service matching 'http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug' - ORF TVThek (com.plexapp.plugins.orftvthek)
2013-10-11 12:04:08,940 (-4fa6b000) : DEBUG (services:41) - Loading service code for ORF TVThek (URLServiceRecord)
2013-10-11 12:04:08,951 (-4fa6b000) : DEBUG (networking:172) - Requesting 'http://resources-cdn.plexapp.com/hashes.json'
2013-10-11 12:04:10,293 (-4fa6b000) : DEBUG (services:41) - Loading service code for Fallback (URLServiceRecord)
2013-10-11 12:04:10,524 (-4fa6b000) : DEBUG (services:615) - Found a service matching 'http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug' - ORF TVThek (com.plexapp.plugins.orftvthek)
2013-10-11 12:04:10,526 (-4fa6b000) : DEBUG (networking:233) - Fetching HTTP headers for 'http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:11,883 (-4fa6b000) : INFO (ServiceCode:86) - Length: 107496 Type: text/html
2013-10-11 12:04:11,884 (-4fa6b000) : DEBUG (networking:172) - Requesting 'http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:14,871 (-4fa6b000) : DEBUG (services:602) - No service found for URL 'ipad:http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:14,871 (-4fa6b000) : DEBUG (services:617) - No matching services found for 'ipad:http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:14,873 (-4fa6b000) : DEBUG (services:602) - No service found for URL 'ipad:http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:14,873 (-4fa6b000) : DEBUG (services:617) - No matching services found for 'ipad:http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:14,875 (-4fa6b000) : DEBUG (networking:233) - Fetching HTTP headers for 'http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:15,353 (-4fa6b000) : INFO (ServiceCode:86) - Length: 107484 Type: text/html
2013-10-11 12:04:15,354 (-4fa6b000) : DEBUG (networking:172) - Requesting 'http://tvthek.orf.at/topics/Unterhaltung/6891999-heute-leben/segments/6892023-Otto-Waalkes-im-Anflug'
2013-10-11 12:04:18,514 (-4fa6b000) : DEBUG (runtime:914) - Response: [404] NoneType, 0 bytes
What am I missing ... ?
Thanks in advance,
alex