Enigma2 plugin to to play various online streams (mostly Latvian).

munkvideoresolver.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # * GNU General Public License for more details.
  2. # *
  3. # * You should have received a copy of the GNU General Public License
  4. # * along with this program; see the file COPYING. If not, write to
  5. # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  6. # * http://www.gnu.org/copyleft/gpl.html
  7. # *
  8. # */
  9. import re,util
  10. __name__='munkvideo'
  11. def supports(url):
  12. return not _regex(url) == None
  13. # returns the steam url
  14. def resolve(url):
  15. m = _regex(url)
  16. if m:
  17. data = util.request(url)
  18. streams = re.search('res0\:[^\"]*\"([^\"]+)',data,re.IGNORECASE|re.DOTALL)
  19. subs = re.search('sub0\:[^\"]*\".*?(http[^\"]*)',data,re.IGNORECASE|re.DOTALL)
  20. rn = re.search('rn\:[^\"]*\"([^\"]*)',data,re.IGNORECASE|re.DOTALL)
  21. if streams and subs and rn:
  22. streams = streams.group(1).split(',')
  23. subs = subs.group(1)
  24. rn = rn.group(1).split(',')
  25. index = 0
  26. result = []
  27. headers = {'Referer':'me'}
  28. for stream in streams:
  29. q = rn[index]
  30. if q == 'HD':
  31. q = '720p'
  32. else:
  33. q = '???'
  34. if len(subs) > 0:
  35. result.append({'url':stream,'quality':q,'subs':subs,'headers':headers})
  36. else:
  37. result.append({'url':stream,'quality':q,'headers':headers})
  38. index+=1
  39. return result
  40. def _regex(url):
  41. return re.search('munkvideo\.cz/video/',url,re.IGNORECASE | re.DOTALL)