lambdascrapers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gostream.py 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # -*- coding: UTF-8 -*-
  2. # -Cleaned and Checked on 11-13-2018 by JewBMX in Scrubs.
  3. import re,traceback,urllib,urlparse,json,base64,time
  4. from resources.lib.modules import cleantitle
  5. from resources.lib.modules import dom_parser2
  6. from resources.lib.modules import client
  7. from resources.lib.modules import debrid
  8. class source:
  9. def __init__(self):
  10. self.priority = 1
  11. self.language = ['en']
  12. self.domains = ['gostream.sc']
  13. self.base_link = 'http://gostream.sc'
  14. self.search_link = '/watch/%s-%s-gostream.html'
  15. def movie(self, imdb, title, localtitle, aliases, year):
  16. try:
  17. clean_title = cleantitle.geturl(title)
  18. url = urlparse.urljoin(self.base_link, (self.search_link %(clean_title,year)))
  19. return url
  20. except:
  21. return
  22. def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year):
  23. try:
  24. aliases.append({'country': 'us', 'title': tvshowtitle})
  25. url = {'imdb': imdb, 'tvdb': tvdb, 'tvshowtitle': tvshowtitle, 'year': year, 'aliases': aliases}
  26. url = urllib.urlencode(url)
  27. return url
  28. except:
  29. return
  30. def episode(self, url, imdb, tvdb, title, premiered, season, episode):
  31. try:
  32. if url == None: return
  33. url = urlparse.parse_qs(url)
  34. url = dict([(i, url[i][0]) if url[i] else (i, '') for i in url])
  35. clean_title = cleantitle.geturl(url['tvshowtitle'])+'-s%02d' % int(season)
  36. url = urlparse.urljoin(self.base_link, (self.search_link %(clean_title,url['year'])))
  37. r = client.request(url)
  38. r = dom_parser2.parse_dom(r, 'div', {'id': 'ip_episode'})
  39. r = [dom_parser2.parse_dom(i, 'a', req=['href']) for i in r if i]
  40. for i in r[0]:
  41. if i.content == 'Episode %s'%episode:
  42. url = i.attrs['href']
  43. return url
  44. except:
  45. return
  46. def sources(self, url, hostDict, hostprDict):
  47. try:
  48. sources = []
  49. if url == None: return sources
  50. r = client.request(url)
  51. quality = re.findall(">(\w+)<\/p",r)
  52. if quality[0] == "HD":
  53. quality = "720p"
  54. else:
  55. quality = "SD"
  56. r = dom_parser2.parse_dom(r, 'div', {'id': 'servers-list'})
  57. r = [dom_parser2.parse_dom(i, 'a', req=['href']) for i in r if i]
  58. for i in r[0]:
  59. url = {'url': i.attrs['href'], 'data-film': i.attrs['data-film'], 'data-server': i.attrs['data-server'], 'data-name' : i.attrs['data-name']}
  60. url = urllib.urlencode(url)
  61. sources.append({'source': i.content, 'quality': quality, 'language': 'en', 'url': url, 'direct': False, 'debridonly': False})
  62. return sources
  63. except:
  64. return sources
  65. def resolve(self, url):
  66. try:
  67. urldata = urlparse.parse_qs(url)
  68. urldata = dict((i, urldata[i][0]) for i in urldata)
  69. post = {'ipplugins': 1,'ip_film': urldata['data-film'], 'ip_server': urldata['data-server'], 'ip_name': urldata['data-name'],'fix': "0"}
  70. p1 = client.request('http://gostream.sc/ip.file/swf/plugins/ipplugins.php', post=post, referer=urldata['url'], XHR=True)
  71. p1 = json.loads(p1)
  72. p2 = client.request('http://gostream.sc/ip.file/swf/ipplayer/ipplayer.php?u=%s&s=%s&n=0' %(p1['s'],urldata['data-server']))
  73. p2 = json.loads(p2)
  74. p3 = client.request('http://gostream.sc/ip.file/swf/ipplayer/api.php?hash=%s' %(p2['hash']))
  75. p3 = json.loads(p3)
  76. n = p3['status']
  77. if n == False:
  78. p2 = client.request('http://gostream.sc/ip.file/swf/ipplayer/ipplayer.php?u=%s&s=%s&n=1' %(p1['s'],urldata['data-server']))
  79. p2 = json.loads(p2)
  80. url = "https:%s" %p2["data"].replace("\/","/")
  81. return url
  82. except:
  83. return