TorrentUplouderBot/tubot/torrent/abc.py

37 lines
987 B
Python

# -*- coding: utf-8 -*-
######################################################
# Abstract methods and interfaces for torrent module #
######################################################
from abc import ABC, abstractmethod
from tubot.static.abc import IValidatable
from tubot.torrent.types import TorrentTypes
class TorrentObj(IValidatable, ABC):
"""
Abstract class of torrent object
"""
_ttype: TorrentTypes # Torrent type property
dest: str
content: str
@property
def torrent_type(self) -> TorrentTypes:
"""
:return: Torrent type
"""
if self._ttype is None:
raise NotImplementedError("Torrent type not implemented")
return self._ttype
def __init__(self, content: str, destination: str) -> None:
"""
:param content: Torrent content (link, file path)
:param destination: Download directory
"""
self.content = content
self.dest = destination