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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # -*- coding: UTF-8 -*-
  2. # /*
  3. # * Copyright (C) 2016 ivars777
  4. # *
  5. # *
  6. # * This Program is free software; you can redistribute it and/or modify
  7. # * it under the terms of the GNU General Public License as published by
  8. # * the Free Software Foundation; either version 2, or (at your option)
  9. # * any later version.
  10. # *
  11. # * This Program is distributed in the hope that it will be useful,
  12. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # * GNU General Public License for more details.
  15. # *
  16. # * You should have received a copy of the GNU General Public License
  17. # * along with this program; see the file COPYING. If not, write to
  18. # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19. # * http://www.gnu.org/copyleft/gpl.html
  20. # *
  21. # */
  22. import re,os,sys
  23. import json
  24. try:
  25. import util
  26. except:
  27. pp = os.path.dirname(os.path.abspath(__file__))
  28. sys.path.insert(0,os.sep.join(pp.split(os.sep)[:-1]))
  29. import util
  30. import urllib2
  31. import requests
  32. from requests.packages.urllib3.exceptions import InsecureRequestWarning
  33. requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
  34. #from aadecode import AADecoder
  35. if __name__ <> "__main__":
  36. __name__ = 'hqq'
  37. def supports(url):
  38. m = re.search(r"https?://hdgo\.\w+/(.+?)$", url, re.DOTALL)
  39. if m:
  40. return True
  41. else:
  42. return False
  43. def resolve(url):
  44. HTTP_HEADER = {
  45. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
  46. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  47. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  48. 'Accept-Encoding': 'none',
  49. 'Accept-Language': 'en-US,en;q=0.8',
  50. 'Referer': url} # 'Connection': 'keep-alive'
  51. streams = []
  52. m = re.search(r"https?://hdgo\.\w+/(.+?)$", url, re.DOTALL)
  53. vid=m.group(1)
  54. url2 = "http://couber.be/"+vid
  55. r = requests.get(url2,headers=HTTP_HEADER)
  56. if r.status_code <> 200:
  57. return streams
  58. m = re.search('<iframe src="([^"]+)"', r.content, re.DOTALL)
  59. if not m: return streams
  60. url3 = m.group(1)
  61. HTTP_HEADER["Rererer"] = url2
  62. r = requests.get(url3,headers=HTTP_HEADER)
  63. m = re.search(r"else{\s+setFlash\('([^']+)'\);", r.content, re.DOTALL)
  64. if not m: return streams
  65. q = ["1080p","720p","480p","360p"]
  66. for i,ss in enumerate(m.group(1).split(",")):
  67. s = ss.split(" or ")
  68. if not s[0]: continue
  69. stream = util.item()
  70. stream["url"] = s[0]
  71. stream["name"] = s[0]
  72. stream["quality"] = q[i]
  73. streams.append(stream)
  74. return streams
  75. if __name__ == "__main__":
  76. from subprocess import call
  77. url = "http://hdgo.cc/video/t/Qrz0riUvA65GtkTpDvmlD9TBOn56HSm2/127280/"
  78. url = "http://hdgo.cc/video/t/Qrz0riUvA65GtkTpDvmlD9TBOn56HSm2/34879/"
  79. streams = resolve(url)
  80. if not streams:
  81. print "No streams found"
  82. sys.exit()
  83. for s in streams:
  84. print s
  85. util.play_video(streams)
  86. #print streams[0]["url"]
  87. #call([r"gst-launch-1.0.exe",'uri="%s""'%streams[0]["url"]])
  88. pass