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.

myvideolink.py 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # -*- coding: UTF-8 -*-
  2. #######################################################################
  3. # ----------------------------------------------------------------------------
  4. # "THE BEER-WARE LICENSE" (Revision 42):
  5. # @tantrumdev wrote this file. As long as you retain this notice you
  6. # can do whatever you want with this stuff. If we meet some day, and you think
  7. # this stuff is worth it, you can buy me a beer in return. - Muad'Dib
  8. # ----------------------------------------------------------------------------
  9. #######################################################################
  10. # -Cleaned and Checked on 10-10-2018 by JewBMX in Yoda.
  11. import re,urllib,urlparse
  12. from resources.lib.modules import cleantitle
  13. from resources.lib.modules import client
  14. from resources.lib.modules import debrid
  15. class source:
  16. def __init__(self):
  17. self.priority = 1
  18. self.language = ['en']
  19. self.domains = ['iwantmyshow.tk','myvideolinks.net']
  20. self.base_link = 'http://iwantmyshow.tk'
  21. self.search_link = '/?s=%s'
  22. def movie(self, imdb, title, localtitle, aliases, year):
  23. try:
  24. url = {'imdb': imdb, 'title': title, 'year': year}
  25. url = urllib.urlencode(url)
  26. return url
  27. except:
  28. return
  29. def sources(self, url, hostDict, hostprDict):
  30. try:
  31. sources = []
  32. if url == None: return sources
  33. if debrid.status() == False: raise Exception()
  34. data = urlparse.parse_qs(url)
  35. data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data])
  36. title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
  37. hdlr = 'S%02dE%02d' % (int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else data['year']
  38. query = '%s S%02dE%02d' % (data['tvshowtitle'], int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else '%s %s' % (data['title'], data['year'])
  39. query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query)
  40. s = client.request(self.base_link)
  41. s = re.findall('\'(http.+?)\'', s) + re.findall('\"(http.+?)\"', s)
  42. s = [i for i in s if urlparse.urlparse(self.base_link).netloc in i and len(i.strip('/').split('/')) > 3]
  43. s = s[0] if s else urlparse.urljoin(self.base_link, 'posts')
  44. s = s.strip('/')
  45. url = s + self.search_link % urllib.quote_plus(query)
  46. r = client.request(url)
  47. r = client.parseDOM(r, 'h2', attrs = {'class': 'post-title'})
  48. r = zip(client.parseDOM(r, 'a', ret='href'), client.parseDOM(r, 'a', ret='title'))
  49. r = [(i[0], i[1], re.sub('(\.|\(|\[|\s)(\d{4}|3D)(\.|\)|\]|\s|)(.+|)', '', i[1]), re.findall('[\.|\(|\[|\s](\d{4}|)([\.|\)|\]|\s|].+)', i[1])) for i in r]
  50. r = [(i[0], i[1], i[2], i[3][0][0], i[3][0][1]) for i in r if i[3]]
  51. r = [(i[0], i[1], i[2], i[3], re.split('\.|\(|\)|\[|\]|\s|\-', i[4])) for i in r]
  52. r = [i for i in r if cleantitle.get(title) == cleantitle.get(i[2]) and data['year'] == i[3]]
  53. r = [i for i in r if not any(x in i[4] for x in ['HDCAM', 'CAM', 'DVDR', 'DVDRip', 'DVDSCR', 'HDTS', 'TS', '3D'])]
  54. r = [i for i in r if '1080p' in i[4]][:1] + [i for i in r if '720p' in i[4]][:1]
  55. posts = [(i[1], i[0]) for i in r]
  56. hostDict = hostprDict + hostDict
  57. items = []
  58. for post in posts:
  59. try:
  60. t = post[0]
  61. u = client.request(post[1])
  62. u = re.findall('\'(http.+?)\'', u) + re.findall('\"(http.+?)\"', u)
  63. u = [i for i in u if not '/embed/' in i]
  64. u = [i for i in u if not 'youtube' in i]
  65. items += [(t, i) for i in u]
  66. except:
  67. pass
  68. for item in items:
  69. try:
  70. name = item[0]
  71. name = client.replaceHTMLCodes(name)
  72. t = re.sub('(\.|\(|\[|\s)(\d{4}|S\d*E\d*|S\d*|3D)(\.|\)|\]|\s|)(.+|)', '', name)
  73. if not cleantitle.get(t) == cleantitle.get(title): raise Exception()
  74. y = re.findall('[\.|\(|\[|\s](\d{4}|S\d*E\d*|S\d*)[\.|\)|\]|\s]', name)[-1].upper()
  75. if not y == hdlr: raise Exception()
  76. fmt = re.sub('(.+)(\.|\(|\[|\s)(\d{4}|S\d*E\d*|S\d*)(\.|\)|\]|\s)', '', name.upper())
  77. fmt = re.split('\.|\(|\)|\[|\]|\s|\-', fmt)
  78. fmt = [i.lower() for i in fmt]
  79. if any(i.endswith(('subs', 'sub', 'dubbed', 'dub')) for i in fmt): raise Exception()
  80. if any(i in ['extras'] for i in fmt): raise Exception()
  81. if '1080p' in fmt: quality = '1080p'
  82. elif '720p' in fmt: quality = 'HD'
  83. else: quality = 'SD'
  84. if any(i in ['dvdscr', 'r5', 'r6'] for i in fmt): quality = 'SCR'
  85. elif any(i in ['camrip', 'tsrip', 'hdcam', 'hdts', 'dvdcam', 'dvdts', 'cam', 'telesync', 'ts'] for i in fmt): quality = 'CAM'
  86. info = []
  87. if '3d' in fmt: info.append('3D')
  88. try:
  89. size = re.findall('((?:\d+\.\d+|\d+\,\d+|\d+) (?:GB|GiB|MB|MiB))', item[2])[-1]
  90. div = 1 if size.endswith(('GB', 'GiB')) else 1024
  91. size = float(re.sub('[^0-9|/.|/,]', '', size))/div
  92. size = '%.2f GB' % size
  93. info.append(size)
  94. except:
  95. pass
  96. if any(i in ['hevc', 'h265', 'x265'] for i in fmt): info.append('HEVC')
  97. info = ' | '.join(info)
  98. url = item[1]
  99. if any(x in url for x in ['.rar', '.zip', '.iso']): raise Exception()
  100. url = client.replaceHTMLCodes(url)
  101. url = url.encode('utf-8')
  102. host = re.findall('([\w]+[.][\w]+)$', urlparse.urlparse(url.strip().lower()).netloc)[0]
  103. if not host in hostDict: raise Exception()
  104. host = client.replaceHTMLCodes(host)
  105. host = host.encode('utf-8')
  106. sources.append({'source': host, 'quality': quality, 'language': 'en', 'url': url, 'info': info, 'direct': False, 'debridonly': True})
  107. except:
  108. pass
  109. check = [i for i in sources if not i['quality'] == 'CAM']
  110. if check: sources = check
  111. return sources
  112. except:
  113. return sources
  114. def resolve(self, url):
  115. return url