2015-01-12, 00:35
I've done extensive search on that matter, so excuse me if this problem was already discussed. I have the following problem:
For security purposes we are using unique URLs for each click. The URL contains a hash that is valid only for about a second and can be used only once. If the URL is opened, the hash is invalidated and can not be used again.
So far so good. My problem is that I can not make Simple (and Kodi for that matter) follow http redirects (302) or open second-level m3u playlist.
The main playlist is something like this:
#EXTM3U
#EXTINF:-1,Channel 1
http://some.com/generate-hash.php?channel=1
#EXTINF:-1,Channel 2
http://some.com/generate-hash.php?channel=2
The script generate-hash.php is pretty simple (for testing purposes). It contains only:
header("Content-type: audio/x-mpegurl");
print "#EXTM3U\n#EXTINF,-1,Live stream\nhttp://some.com/static-stream-for-test";
Unfortunately, this does not work. Kodi / Simple makes one HEAD request to http://some.com/generate-hash.php?channel=1, then one GET request to the same address and that's all - the link inside the second m3u list (http://some.com/static-stream-for-test) is never opened.
I have tried to trick Kodi / Simple to think the URL is an m3u playlist by adding an extension:
#EXTM3U
#EXTINF:-1,Channel 1
http://some.com/generate-hash.php?channel=1&ext=.m3u
#EXTINF:-1,Channel 2
http://some.com/generate-hash.php?channel=2&ext=.m3u8
but to no avail.
So I have modified the generate-hash.php to look like this:
header("Location: http://some.com/static-stream-for-test");
Now Kodi / Simple is generating 3 requests: HEAD request to http://some.com/generate-hash.php?channel=1, then after receiving the 302 answer - another HEAD request to http://some.com/static-stream-for-test, and a GET request to (!!!) http://some.com/generate-hash.php?channel=1 instead of http://some.com/static-stream-for-test
It looks like Simple (or Kodi) does not support second-level m3u's and does not support HTTP redirects either (although it DOES follow the 302 redirect on the HEAD phase, but not on the GET one).
BTW, the HEAD phase makes me nervous, as in real life it invalidates the hash, because the hash can be used one-time only and the streaming server does not support HEAD requests, translating them to GET. But that's another story. I will think about how to get rid of this unneeded HEAD request later.
So, does anyone knows a solution of my original problem - a unique, one-time-only URL, generated on-the-fly for each click on the channel?
For security purposes we are using unique URLs for each click. The URL contains a hash that is valid only for about a second and can be used only once. If the URL is opened, the hash is invalidated and can not be used again.
So far so good. My problem is that I can not make Simple (and Kodi for that matter) follow http redirects (302) or open second-level m3u playlist.
The main playlist is something like this:
#EXTM3U
#EXTINF:-1,Channel 1
http://some.com/generate-hash.php?channel=1
#EXTINF:-1,Channel 2
http://some.com/generate-hash.php?channel=2
The script generate-hash.php is pretty simple (for testing purposes). It contains only:
header("Content-type: audio/x-mpegurl");
print "#EXTM3U\n#EXTINF,-1,Live stream\nhttp://some.com/static-stream-for-test";
Unfortunately, this does not work. Kodi / Simple makes one HEAD request to http://some.com/generate-hash.php?channel=1, then one GET request to the same address and that's all - the link inside the second m3u list (http://some.com/static-stream-for-test) is never opened.
I have tried to trick Kodi / Simple to think the URL is an m3u playlist by adding an extension:
#EXTM3U
#EXTINF:-1,Channel 1
http://some.com/generate-hash.php?channel=1&ext=.m3u
#EXTINF:-1,Channel 2
http://some.com/generate-hash.php?channel=2&ext=.m3u8
but to no avail.
So I have modified the generate-hash.php to look like this:
header("Location: http://some.com/static-stream-for-test");
Now Kodi / Simple is generating 3 requests: HEAD request to http://some.com/generate-hash.php?channel=1, then after receiving the 302 answer - another HEAD request to http://some.com/static-stream-for-test, and a GET request to (!!!) http://some.com/generate-hash.php?channel=1 instead of http://some.com/static-stream-for-test
It looks like Simple (or Kodi) does not support second-level m3u's and does not support HTTP redirects either (although it DOES follow the 302 redirect on the HEAD phase, but not on the GET one).
BTW, the HEAD phase makes me nervous, as in real life it invalidates the hash, because the hash can be used one-time only and the streaming server does not support HEAD requests, translating them to GET. But that's another story. I will think about how to get rid of this unneeded HEAD request later.
So, does anyone knows a solution of my original problem - a unique, one-time-only URL, generated on-the-fly for each click on the channel?