added okru parser

This commit is contained in:
2023-09-27 02:31:46 +03:00
parent 493cde3f29
commit b17bed48c3
3 changed files with 31 additions and 3 deletions

View 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()

View File

@ -1,7 +1,7 @@
import errno
import os
# from loguru import logger
from loguru import logger
from src.core.ydl import VideoDownloader
from src.exceptions.download_exceptions import FileAlreadyExistException
@ -17,7 +17,7 @@ class BaseParser:
def video_download(self):
ydl_opts = {
"format": self.params["format"],
# "logger": logger,
"logger": logger,
"merge_output_format": self.params["merge_output_format"],
'outtmpl': self.params["outtmpl"],
"quiet": True