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

hdgo.py 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 aadecode import AADecoder
  33. if __name__ <> "__main__":
  34. __name__ = 'hqq'
  35. def supports(url):
  36. m = re.search(r"https?://hdgo\.\w+/(.+?)$", url, re.DOTALL)
  37. if m:
  38. return True
  39. else:
  40. return False
  41. def resolve(url):
  42. HTTP_HEADER = {
  43. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
  44. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  45. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  46. 'Accept-Encoding': 'none',
  47. 'Accept-Language': 'en-US,en;q=0.8',
  48. 'Referer': url} # 'Connection': 'keep-alive'
  49. streams = []
  50. m = re.search(r"https?://hdgo\.\w+/(.+?)$", url, re.DOTALL)
  51. vid=m.group(1)
  52. url2 = "http://couber.be/"+vid
  53. r = requests.get(url2,headers=HTTP_HEADER)
  54. if r.status_code <> 200:
  55. return streams
  56. m = re.search('<iframe src="([^"]+)"', r.content, re.DOTALL)
  57. if not m: return streams
  58. url3 = m.group(1)
  59. HTTP_HEADER["Rererer"] = url2
  60. r = requests.get(url3,headers=HTTP_HEADER)
  61. m = re.search(r"else{\s+setFlash\('([^']+)'\);", r.content, re.DOTALL)
  62. if not m: return streams
  63. q = ["1080p","720p","480p","360p"]
  64. for i,ss in enumerate(m.group(1).split(",")):
  65. s = ss.split(" or ")
  66. if not s[0]: continue
  67. stream = util.item()
  68. stream["url"] = s[0]
  69. stream["name"] = s[0]
  70. stream["quality"] = q[i]
  71. streams.append(stream)
  72. return streams
  73. if __name__ == "__main__":
  74. from subprocess import call
  75. url = "http://hdgo.cc/video/t/Qrz0riUvA65GtkTpDvmlD9TBOn56HSm2/127280/"
  76. url = "http://hdgo.cc/video/t/Qrz0riUvA65GtkTpDvmlD9TBOn56HSm2/34879/"
  77. streams = resolve(url)
  78. if not streams:
  79. print "No streams found"
  80. sys.exit()
  81. for s in streams:
  82. print s
  83. util.play_video(streams)
  84. #print streams[0]["url"]
  85. #call([r"gst-launch-1.0.exe",'uri="%s""'%streams[0]["url"]])
  86. pass