lf_search.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import requests
  2. import sys
  3. from bs4 import BeautifulSoup as bs
  4. from plugins.plugin import Plugin
  5. sys.path.append("..")
  6. from src.video import Video
  7. from src.history import History
  8. from src.config import Config
  9. class LordFilmsSearch(Plugin):
  10. def __init__(self, history: History=History(), config: Config=Config()) -> None:
  11. super().__init__(history, config)
  12. self.history = history
  13. self.config = config
  14. self.name = "[-] LordFilms: Search"
  15. self.category = "LordFilms"
  16. self.params = {
  17. 'query' : True
  18. }
  19. self.flag = "-lfs"
  20. self.full_flag = "--lordfilmssearch"
  21. self.flag_help = "show films from lordfilms mirror"
  22. self.flag_action = "store_true"
  23. def get_search(self, search):
  24. torrents = list()
  25. html = requests.get("https://torrenther.com/")
  26. soup = bs(html.text, 'html.parser')
  27. for video_box in soup.find_all("div", {"class": "d1shortss"}):
  28. vpage_url = video_box.find("a", href=True)['href']
  29. title = video_box.find("a", {"class" : "d1short-name"}).text
  30. v_html = requests.get(vpage_url)
  31. v_soup = bs(v_html.text, 'html.parser')
  32. torrent_url = v_soup.find("div", {"id": "download"}).find("a", href=True)['href']
  33. print(title, torrent_url)
  34. torrent = Torrent(title=title, url=torrent_url)
  35. torrents.append(torrent.to_json())
  36. return torrents
  37. def get_torrents(self):
  38. torrents = self.get_torrenther()
  39. return torrents
  40. def get_items(self, params):
  41. query = ""
  42. if 'query' in params:
  43. query = params['query']
  44. return self.get_films(query)