mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-06-09 19:37:25 +08:00
@@ -28,10 +28,15 @@ import aiofiles
|
|||||||
|
|
||||||
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
||||||
from tools import utils
|
from tools import utils
|
||||||
|
import config
|
||||||
|
|
||||||
|
|
||||||
class BilibiliVideo(AbstractStoreVideo):
|
class BilibiliVideo(AbstractStoreVideo):
|
||||||
video_store_path: str = "data/bili/videos"
|
def __init__(self):
|
||||||
|
if config.SAVE_DATA_PATH:
|
||||||
|
self.video_store_path = f"{config.SAVE_DATA_PATH}/bili/videos"
|
||||||
|
else:
|
||||||
|
self.video_store_path = "data/bili/videos"
|
||||||
|
|
||||||
async def store_video(self, video_content_item: Dict):
|
async def store_video(self, video_content_item: Dict):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -24,10 +24,15 @@ import aiofiles
|
|||||||
|
|
||||||
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
||||||
from tools import utils
|
from tools import utils
|
||||||
|
import config
|
||||||
|
|
||||||
|
|
||||||
class DouYinImage(AbstractStoreImage):
|
class DouYinImage(AbstractStoreImage):
|
||||||
image_store_path: str = "data/douyin/images"
|
def __init__(self):
|
||||||
|
if config.SAVE_DATA_PATH:
|
||||||
|
self.image_store_path = f"{config.SAVE_DATA_PATH}/douyin/images"
|
||||||
|
else:
|
||||||
|
self.image_store_path = "data/douyin/images"
|
||||||
|
|
||||||
async def store_image(self, image_content_item: Dict):
|
async def store_image(self, image_content_item: Dict):
|
||||||
"""
|
"""
|
||||||
@@ -74,7 +79,11 @@ class DouYinImage(AbstractStoreImage):
|
|||||||
|
|
||||||
|
|
||||||
class DouYinVideo(AbstractStoreVideo):
|
class DouYinVideo(AbstractStoreVideo):
|
||||||
video_store_path: str = "data/douyin/videos"
|
def __init__(self):
|
||||||
|
if config.SAVE_DATA_PATH:
|
||||||
|
self.video_store_path = f"{config.SAVE_DATA_PATH}/douyin/videos"
|
||||||
|
else:
|
||||||
|
self.video_store_path = "data/douyin/videos"
|
||||||
|
|
||||||
async def store_video(self, video_content_item: Dict):
|
async def store_video(self, video_content_item: Dict):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ except ImportError:
|
|||||||
|
|
||||||
from base.base_crawler import AbstractStore
|
from base.base_crawler import AbstractStore
|
||||||
from tools import utils
|
from tools import utils
|
||||||
|
import config
|
||||||
|
|
||||||
|
|
||||||
class ExcelStoreBase(AbstractStore):
|
class ExcelStoreBase(AbstractStore):
|
||||||
@@ -111,6 +112,9 @@ class ExcelStoreBase(AbstractStore):
|
|||||||
self.crawler_type = crawler_type
|
self.crawler_type = crawler_type
|
||||||
|
|
||||||
# Create data directory
|
# Create data directory
|
||||||
|
if config.SAVE_DATA_PATH:
|
||||||
|
self.data_dir = Path(config.SAVE_DATA_PATH) / platform
|
||||||
|
else:
|
||||||
self.data_dir = Path("data") / platform
|
self.data_dir = Path("data") / platform
|
||||||
self.data_dir.mkdir(parents=True, exist_ok=True)
|
self.data_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,15 @@ import aiofiles
|
|||||||
|
|
||||||
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
||||||
from tools import utils
|
from tools import utils
|
||||||
|
import config
|
||||||
|
|
||||||
|
|
||||||
class WeiboStoreImage(AbstractStoreImage):
|
class WeiboStoreImage(AbstractStoreImage):
|
||||||
image_store_path: str = "data/weibo/images"
|
def __init__(self):
|
||||||
|
if config.SAVE_DATA_PATH:
|
||||||
|
self.image_store_path = f"{config.SAVE_DATA_PATH}/weibo/images"
|
||||||
|
else:
|
||||||
|
self.image_store_path = "data/weibo/images"
|
||||||
|
|
||||||
async def store_image(self, image_content_item: Dict):
|
async def store_image(self, image_content_item: Dict):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -28,10 +28,15 @@ import aiofiles
|
|||||||
|
|
||||||
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
from base.base_crawler import AbstractStoreImage, AbstractStoreVideo
|
||||||
from tools import utils
|
from tools import utils
|
||||||
|
import config
|
||||||
|
|
||||||
|
|
||||||
class XiaoHongShuImage(AbstractStoreImage):
|
class XiaoHongShuImage(AbstractStoreImage):
|
||||||
image_store_path: str = "data/xhs/images"
|
def __init__(self):
|
||||||
|
if config.SAVE_DATA_PATH:
|
||||||
|
self.image_store_path = f"{config.SAVE_DATA_PATH}/xhs/images"
|
||||||
|
else:
|
||||||
|
self.image_store_path = "data/xhs/images"
|
||||||
|
|
||||||
async def store_image(self, image_content_item: Dict):
|
async def store_image(self, image_content_item: Dict):
|
||||||
"""
|
"""
|
||||||
@@ -78,7 +83,11 @@ class XiaoHongShuImage(AbstractStoreImage):
|
|||||||
|
|
||||||
|
|
||||||
class XiaoHongShuVideo(AbstractStoreVideo):
|
class XiaoHongShuVideo(AbstractStoreVideo):
|
||||||
video_store_path: str = "data/xhs/videos"
|
def __init__(self):
|
||||||
|
if config.SAVE_DATA_PATH:
|
||||||
|
self.video_store_path = f"{config.SAVE_DATA_PATH}/xhs/videos"
|
||||||
|
else:
|
||||||
|
self.video_store_path = "data/xhs/videos"
|
||||||
|
|
||||||
async def store_video(self, video_content_item: Dict):
|
async def store_video(self, video_content_item: Dict):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user