added okru parser
This commit is contained in:
parent
c66ef29069
commit
2f7ba6b24e
@ -12,6 +12,7 @@ from src.core.redis_client import RedisClient
|
|||||||
from src.core.result import Result, ResultTypeEnum
|
from src.core.result import Result, ResultTypeEnum
|
||||||
from src.exceptions.download_exceptions import FileAlreadyExistException, SiteNotImplementedException
|
from src.exceptions.download_exceptions import FileAlreadyExistException, SiteNotImplementedException
|
||||||
from src.parsers.MyMail.my_mail_parser import MyMailParser
|
from src.parsers.MyMail.my_mail_parser import MyMailParser
|
||||||
|
from src.parsers.Okru.ok_parser import OkParser
|
||||||
from src.parsers.Yappy.yappy_parser import YappyParser
|
from src.parsers.Yappy.yappy_parser import YappyParser
|
||||||
from src.parsers.base_parser import BaseParser
|
from src.parsers.base_parser import BaseParser
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ class MasterService:
|
|||||||
"www.youtube.com": BaseParser(params),
|
"www.youtube.com": BaseParser(params),
|
||||||
"youtu.be": BaseParser(params),
|
"youtu.be": BaseParser(params),
|
||||||
"vk.com": BaseParser(params),
|
"vk.com": BaseParser(params),
|
||||||
"ok.ru": BaseParser(params),
|
"ok.ru": BaseParser(params) if "topic" not in params["link"] else OkParser(params),
|
||||||
"likee.video": BaseParser(params),
|
"likee.video": BaseParser(params),
|
||||||
"dzen.ru": BaseParser(params),
|
"dzen.ru": BaseParser(params),
|
||||||
"yappy.media": YappyParser(params),
|
"yappy.media": YappyParser(params),
|
||||||
|
27
src/parsers/Okru/ok_parser.py
Normal file
27
src/parsers/Okru/ok_parser.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
from src.parsers.base_parser import BaseParser
|
||||||
|
|
||||||
|
|
||||||
|
class OkParser(BaseParser):
|
||||||
|
BASE_DIR = os.path.abspath(f"downloads/Odnoklassniki")
|
||||||
|
|
||||||
|
def get_video_link(self):
|
||||||
|
try:
|
||||||
|
resp = requests.get(self.params["link"])
|
||||||
|
resp.encoding = self.BASE_ENCODING
|
||||||
|
soup = BeautifulSoup(resp.text, 'lxml')
|
||||||
|
required_div = [div for div in soup.find_all('div', {'class': 'invisible'}) if len(div['class']) < 2][0]
|
||||||
|
link = required_div.find('span').find('span').find('a').get("href")
|
||||||
|
self.params["link"] = link
|
||||||
|
return link
|
||||||
|
except Exception as ex:
|
||||||
|
raise
|
||||||
|
|
||||||
|
def video_download(self):
|
||||||
|
self.get_video_link()
|
||||||
|
super().video_download()
|
@ -1,7 +1,7 @@
|
|||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from src.core.ydl import VideoDownloader
|
from src.core.ydl import VideoDownloader
|
||||||
from src.exceptions.download_exceptions import FileAlreadyExistException
|
from src.exceptions.download_exceptions import FileAlreadyExistException
|
||||||
@ -17,7 +17,7 @@ class BaseParser:
|
|||||||
def video_download(self):
|
def video_download(self):
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
"format": self.params["format"],
|
"format": self.params["format"],
|
||||||
# "logger": logger,
|
"logger": logger,
|
||||||
"merge_output_format": self.params["merge_output_format"],
|
"merge_output_format": self.params["merge_output_format"],
|
||||||
'outtmpl': self.params["outtmpl"],
|
'outtmpl': self.params["outtmpl"],
|
||||||
"quiet": True
|
"quiet": True
|
||||||
|
Loading…
Reference in New Issue
Block a user