start.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # -*- coding: utf-8 -*-
  2. from bs4 import BeautifulSoup as bs
  3. import requests
  4. import re
  5. from pyfzf.pyfzf import FzfPrompt
  6. import os
  7. print("Загрузка....")
  8. f = [i.strip('\n').split(',') for i in open('subscribe.txt')]
  9. chanel_list = []
  10. for k in f:
  11. h = (k[0])
  12. pre_source = requests.get(h)
  13. pre_source.encoding = 'utf-8'
  14. pre_soup = bs(pre_source.text, 'html.parser')
  15. pre_name = pre_soup.select("span")
  16. pre_name1 = pre_name[1]
  17. pre_canell = (pre_name1.text)
  18. chanel_list.append(pre_canell)
  19. fzf = FzfPrompt()
  20. target_chanel=fzf.prompt(chanel_list)
  21. print(target_chanel[0])
  22. nomber_chanel = (chanel_list.index(target_chanel[0]))
  23. url = f[nomber_chanel]
  24. end_url = url[0]
  25. source = requests.get(end_url)
  26. source.encoding = 'utf-8'
  27. soup = bs(source.text, 'html.parser')
  28. name = soup.select("span")
  29. name1 = name[1]
  30. canell = (name1.text)
  31. spisokNAME=[]
  32. z=0
  33. for title in soup.select("div p"):
  34. kkk = title.find('a')
  35. if kkk is not None:
  36. xxx = kkk
  37. ggg=xxx.text
  38. if re.search(canell, ggg):
  39. a = 1
  40. else:
  41. z=z+1
  42. if z >= 2:
  43. spisokNAME.append(ggg)
  44. target=fzf.prompt(spisokNAME)
  45. print(target[0])
  46. nomber = (spisokNAME.index(target[0]))
  47. spisok=[]
  48. for a in soup.find_all('a', href=True):
  49. link=(a['href'])
  50. if re.search(r'com/watch\b', link):
  51. spisok.append(link)
  52. end_target = spisok[nomber]
  53. comand = "mpv " + end_target
  54. os.system(comand)