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.

bestmoviez.py 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. # -*- coding: UTF-8 -*-
  2. #######################################################################
  3. # ----------------------------------------------------------------------------
  4. # "THE BEER-WARE LICENSE" (Revision 42):
  5. # @Daddy_Blamo 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. # Scraper Checked and Fixed 11-08-2018 -JewBMX
  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. from resources.lib.modules import log_utils
  16. from resources.lib.modules import source_utils
  17. from resources.lib.modules import cfscrape
  18. # Working: https://www.best-moviez.ws/deadpool-2-2018-1080p-web-dl-dd5-1-h264-cmrg/
  19. # Working: https://www.best-moviez.ws/deadpool-2-2018
  20. # Working: https://www.best-moviez.ws/deadpool-2
  21. # Working: https://www.best-moviez.ws/deadpool--2--2018
  22. # Failed: https://www.best-moviez.ws/Deadpool+2+2018
  23. class source:
  24. def __init__(self):
  25. self.priority = 1
  26. self.language = ['en']
  27. self.domains = ['best-moviez.ws']
  28. self.base_link = 'http://www.best-moviez.ws'
  29. self.search_link = '/%s'
  30. def movie(self, imdb, title, localtitle, aliases, year):
  31. try:
  32. url = {'imdb': imdb, 'title': title, 'year': year}
  33. url = urllib.urlencode(url)
  34. return url
  35. except:
  36. return
  37. def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year):
  38. try:
  39. url = {'imdb': imdb, 'tvdb': tvdb, 'tvshowtitle': tvshowtitle, 'year': year}
  40. url = urllib.urlencode(url)
  41. return url
  42. except:
  43. return
  44. def episode(self, url, imdb, tvdb, title, premiered, season, episode):
  45. try:
  46. if url == None: return
  47. url = urlparse.parse_qs(url)
  48. url = dict([(i, url[i][0]) if url[i] else (i, '') for i in url])
  49. url['title'], url['premiered'], url['season'], url['episode'] = title, premiered, season, episode
  50. url = urllib.urlencode(url)
  51. return url
  52. except:
  53. return
  54. def sources(self, url, hostDict, hostprDict):
  55. try:
  56. sources = []
  57. scraper = cfscrape.create_scraper()
  58. if url == None: return sources
  59. if debrid.status() == False: raise Exception()
  60. data = urlparse.parse_qs(url)
  61. data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data])
  62. title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
  63. hdlr = 'S%02dE%02d' % (int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else data['year']
  64. query = '%s s%02de%02d' % (data['tvshowtitle'], int(data['season']), int(data['episode'])) if 'tvshowtitle' in data else '%s %s' % (data['title'], data['year'])
  65. query = re.sub('[\\\\:;*?"<>|/ \+\']+', '-', query)
  66. url = self.search_link % urllib.quote_plus(query)
  67. url = urlparse.urljoin(self.base_link, url)
  68. #log_utils.log('\n\n\n\n\n\nquery, url: %s, %s' % (query,url))
  69. r = scraper.get(url).content
  70. # grab the (only?) relevant div and cut off the footer
  71. r = client.parseDOM(r, "div", attrs={'class': 'entry-content'})[0]
  72. r = re.sub('shareaholic-canvas.+', '', r, flags=re.DOTALL)
  73. # gather actual <a> links then clear all <a>/<img> to prep for naked-url scan
  74. # inner text could be useful if url looks like http://somehost.com/ugly_hash_377cbc738eff
  75. a_txt = ''
  76. a_url = ''
  77. a_txt = client.parseDOM(r, "a", attrs={'href': '.+?'})
  78. a_url = client.parseDOM(r, "a", ret = "href")
  79. r = re.sub('<a .+?</a>', '', r, flags=re.DOTALL)
  80. r = re.sub('<img .+?>', '', r, flags=re.DOTALL)
  81. # check pre blocks for size and gather naked-urls
  82. size = ''
  83. pre_txt = []
  84. pre_url = []
  85. pres = client.parseDOM(r, "pre", attrs={'style': '.+?'})
  86. for pre in pres:
  87. try: size = re.findall('([0-9,\.]+ ?(?:GB|GiB|MB|MiB))', pre)[0]
  88. except: pass
  89. url0 = re.findall('https?://[^ <"\'\s]+', pre, re.DOTALL) # bad form but works with this site
  90. txt0 = [size] * len(url0)
  91. pre_url = pre_url + url0
  92. pre_txt = pre_txt + txt0 # we're just grabbing raw urls so there's no other info
  93. r = re.sub('<pre .+?</pre>', '', r, flags=re.DOTALL)
  94. # assume info at page top is true for all movie links, and only movie links
  95. # (and that otherwise, only <pre>'s have scrapable sizes)
  96. size = ''
  97. if not 'tvshowtitle' in data:
  98. try: size = " " + re.findall('([0-9,\.]+ ?(?:GB|GiB|MB|MiB))', r)[0]
  99. except: pass
  100. # get naked urls (after exhausting <a>'s and <pre>'s)
  101. # note: all examples use full titles in links, so we can be careful
  102. raw_url = re.findall('https?://[^ <"\'\s]+', r, re.DOTALL) # bad form but works with this site
  103. raw_txt = [size] * len(raw_url) # we're just grabbing raw urls so there's no other info
  104. # combine the 3 types of scrapes
  105. pairs = zip(a_url+pre_url+raw_url, a_txt+pre_txt+raw_txt)
  106. for pair in pairs:
  107. try:
  108. url = str(pair[0])
  109. info = re.sub('<.+?>','',pair[1]) #+ size # usually (??) no <span> inside
  110. # immediately abandon pairs with undesired traits
  111. # (if they stop using urls w/ titles, would need to accomodate here)
  112. if any(x in url for x in ['.rar', '.zip', '.iso']): raise Exception()
  113. if not query.lower() in re.sub('[\\\\:;*?"<>|/ \+\'\.]+', '-', url+info).lower(): raise Exception()
  114. # establish size0 for this pair: 'size' is pre-loaded for movies only...
  115. # ...but prepend 'info' to lead with more-specific sizes (from a <pre>)
  116. size0 = info + " " + size
  117. # grab first reasonable data size from size0 string
  118. try:
  119. size0 = re.findall('([0-9,\.]+ ?(?:GB|GiB|MB|MiB))', size0)[0]
  120. div = 1 if size0.endswith(('GB', 'GiB')) else 1024
  121. size0 = float(re.sub('[^0-9\.]', '', size0)) / div
  122. size0 = '%.2f GB' % size0
  123. except:
  124. size0 = ''
  125. pass
  126. # process through source_tools and hint with size0
  127. quality, info = source_utils.get_release_quality(url,info)
  128. info.append(size0)
  129. info = ' | '.join(info)
  130. #log_utils.log('** pair: [%s / %s] %s' % (quality,info,url))
  131. url = url.encode('utf-8')
  132. hostDict = hostDict + hostprDict
  133. valid, host = source_utils.is_host_valid(url, hostDict)
  134. if not valid: continue
  135. sources.append({'source': host, 'quality': quality, 'language': 'en', 'url': url,
  136. 'info': info, 'direct': False, 'debridonly': True})
  137. except:
  138. pass
  139. return sources
  140. except:
  141. return sources
  142. def resolve(self, url):
  143. return url
  144. '''
  145. EXAMPLE: text urls after "Single Link" (note no "S")
  146. <div class="entry-content">
  147. <div style="text-align:center"><img src="https://i103.fastpic.ru/big/2018/0808/81/371ccc697bd9da5d664322cee07a1581.jpg" /></div>
  148. <div style="text-align:center"><span style="font-weight:bold">Deadpool 2 (2018) 720p BluRay x264 DTS-HDC</span><br />
  149. <span style="font-weight:bold">Language(s)</span>: English<br />
  150. 01:59:00 | 1280&#215;536 @ 6200 kb/s | 23.98 fps(r) | DTS, 44100 Hz, 6CH, 1509 kb/s | 6.42 GB<br />
  151. <span style="font-weight:bold">Genre(s)</span>: Action, Adventure, Comedy<br />
  152. <a href="https://www.imdb.com/title/tt5463162/"><span style="font-weight:bold">IMDB</span></a></div>
  153. <p><span id="more-75092"></span></p>
  154. <div style="text-align:center"> Foul-mouthed mutant mercenary Wade Wilson (AKA. Deadpool), brings together a team of fellow mutant rogues to protect a young boy with supernatural abilities from the brutal, time-traveling cyborg, Cable.</p>
  155. ...
  156. <span style="font-weight:bold"><span style="color:#FF0000">Download</span></span></p>
  157. <p><span style="font-weight:bold"><span style="color:#00BF00">Single Link</span></span></p>
  158. <p>http://nitroflare.com/view/4424F59C04B5172/Deadpool.2.2018.720p.BluRay.x264.DTS-HDC.mkv</p>
  159. <p><span style="font-weight:bold"><span style="color:#0080FF">NitroFlare</span></span></p>
  160. <p>http://nitroflare.com/view/F8885D081E8036B/Deadpool.2.2018.720p.BluRay.x264.DTS-HDC.part1.rar<br />
  161. EXAMPLE: <a> links after "Single Links" (note now there is an "S")
  162. <div class="entry-content">
  163. ...
  164. <p><b><span style="color: #ff0000">DownLoad</b></span></p>
  165. <p><b><span style="color: #ff0000">Single Links</b></span><br />
  166. <a href="https://nitroflare.com/view/B79F3390ED3305B/Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.mkv">Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.mkv</a></p>
  167. <p><a href="https://uploadgig.com/file/download/f8e5B103e779F0a4/Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.mkv">Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.mkv</a></p>
  168. <p><b><span style="color: #ff0000">NitroFlare</b></span><br />
  169. <a href="https://nitroflare.com/view/9EACE029F149096/Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.part01.rar">Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.part01.rar</a><br />
  170. <a href="https://nitroflare.com/view/5F167E50AFBCDD7/Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.part02.rar">Avengers.Infinity.War.2018.2160p.UHD.BluRay.x265-SWTYBLZ.part02.rar</a><br />
  171. EXAMPLE: <a> link but to a .iso file
  172. <div class="entry-content">
  173. ...
  174. <p><b><span style="color: #ff0000">DownLoad</b></span></p>
  175. <p><b><span style="color: #ff0000">Single Link</b></span><br />
  176. <a href="https://nitroflare.com/view/D0ADAE9780B6340/Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.iso">Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.iso</a></p>
  177. <p><a href="https://uploadgig.com/file/download/5c02b57c909968cf/Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.iso">Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.iso</a></p>
  178. <p><b><span style="color: #ff0000">NitroFlare</b></span><br />
  179. <a href="https://nitroflare.com/view/435E34B243AEEC1/Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.part01.rar">Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.part01.rar</a><br />
  180. <a href="https://nitroflare.com/view/D11B2E1CEEB4D00/Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.part02.rar">Avengers.Age.Of.Ultron.UHDBD-TERMiNAL.part02.rar</a><br />
  181. EXAMPLE: Plain text inside sometimes-shared) <p> tags
  182. <div class="entry-content">
  183. ...
  184. <span style="font-weight:bold"><span style="color:#FF0000">Download</span></span></p>
  185. <p><span style="font-weight:bold"><span style="color:#00BF00">Single Link</span></span></p>
  186. <p>http://nitroflare.com/view/FBBCB2B4E2FE486/The.Death.of.Superman.2018.1080p.BluRay.DTS.x264-TayTO.mkv</p>
  187. <p>
  188. <span style="font-weight:bold"><span style="color:#0080FF">NitroFlare</span></span></p>
  189. <p>http://nitroflare.com/view/EAF5BF83036A8DE/The.Death.of.Superman.2018.1080p.BluRay.DTS.x264-TayTO.part1.rar<br />
  190. http://nitroflare.com/view/290A3D1480AD822/The.Death.of.Superman.2018.1080p.BluRay.DTS.x264-TayTO.part2.rar<br />
  191. EXAMPLE: tv episode text links in <pre>, by type/quality
  192. <div class="entry-content">
  193. ...
  194. <span style="font-weight:bold">[LiNKs]</span></p>
  195. <pre style="background:#BBBBBB"><br />
  196. ===================================================<br />
  197. ➡ Better.Call.Saul.S04E01.HDTV.x264-SVA<br />
  198. ===================================================<br /><br />
  199. http://nitroflare.com/view/8E5BBDBD5378EB2/Better.Call.Saul.S04E01.HDTV.x264-SVA.mkv<br />
  200. https://rapidgator.net/file/b1abba0d3fac85c7b4adecf2b194734d/Better.Call.Saul.S04E01.HDTV.x264-SVA.mkv.html<br />
  201. https://uploadgig.com/file/download/e5c4bf10a454144A/Better.Call.Saul.S04E01.HDTV.x264-SVA.mkv<br />
  202. https://k2s.cc/file/1e8490e210630/Better.Call.Saul.S04E01.HDTV.x264-SVA.mkv<br /><br />
  203. ===================================================<br />
  204. ➡ Better.Call.Saul.S04E01.720p.HDTV.x264-AVS<br />
  205. ===================================================<br /><br />
  206. http://nitroflare.com/view/338D7D912CF954E/Better.Call.Saul.S04E01.720p.HDTV.x264-AVS.mkv<br />
  207. https://rapidgator.net/file/f016b7ef0aed23a7eda75b459567a46a/Better.Call.Saul.S04E01.720p.HDTV.x264-AVS.mkv.html<br />
  208. https://uploadgig.com/file/download/d671D3e4dD7e9385/Better.Call.Saul.S04E01.720p.HDTV.x264-AVS.mkv<br />
  209. https://k2s.cc/file/9622e3c5abda5/Better.Call.Saul.S04E01.720p.HDTV.x264-AVS.mp4<br /><br />
  210. ===================================================<br />
  211. ➡ Better.Call.Saul.S04E01.HDTV.XviD-AFG [P2P]<br />
  212. ===================================================<br /><br />
  213. http://nitroflare.com/view/DC7D1E0637F69DE/Better.Call.Saul.S04E01.XviD-AFG.avi<br />
  214. https://rapidgator.net/file/e07a34e09bf8fa8490096a556106c7a3/Better.Call.Saul.S04E01.XviD-AFG.avi.html<br />
  215. https://uploadgig.com/file/download/939Ddb7e78ba3994/Better.Call.Saul.S04E01.XviD-AFG.avi<br />
  216. https://k2s.cc/file/7511e23d723cc/Better.Call.Saul.S04E01.XviD-AFG.mp4<br />
  217. </pre>
  218. '''