mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Work on provider manager and UI
This commit is contained in:
@ -20,6 +20,9 @@ class DummyVideoProvider(VideoProvider):
|
||||
def configure(self, configuration: Dict[str, Any]) -> None:
|
||||
print(configuration)
|
||||
|
||||
def unconfigure(self):
|
||||
pass
|
||||
|
||||
def validate_configuration(self, configuration: Dict[str, Any]):
|
||||
print("Validating...")
|
||||
if configuration["number_of_something"] >= 10:
|
||||
|
@ -1,4 +1,5 @@
|
||||
from abc import abstractmethod, ABC
|
||||
from enum import Enum
|
||||
from typing import Dict, Iterable, List, Any
|
||||
|
||||
from django.forms import Field
|
||||
@ -6,6 +7,12 @@ from django.forms import Field
|
||||
from YtManagerApp.models import Subscription, Video
|
||||
|
||||
|
||||
class VideoProviderState(Enum):
|
||||
NOT_CONFIGURED = 0
|
||||
OK = 1
|
||||
ERROR = 2
|
||||
|
||||
|
||||
class ProviderValidationError(ValueError):
|
||||
"""
|
||||
Exception type thrown when validating configurations.
|
||||
@ -44,6 +51,9 @@ class VideoProvider(ABC):
|
||||
"""
|
||||
settings: Dict[str, Field] = {}
|
||||
|
||||
def __init__(self):
|
||||
self.state = VideoProviderState.NOT_CONFIGURED
|
||||
|
||||
@abstractmethod
|
||||
def configure(self, configuration: Dict[str, Any]) -> None:
|
||||
"""
|
||||
@ -53,6 +63,14 @@ class VideoProvider(ABC):
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def unconfigure(self) -> None:
|
||||
"""
|
||||
Destroys video provider configuration
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def validate_configuration(self, configuration: Dict[str, Any]) -> None:
|
||||
"""
|
||||
|
@ -25,6 +25,10 @@ class YouTubeApiVideoProvider(VideoProvider):
|
||||
self.__api_key = configuration['api_key']
|
||||
self.__api = yt.YouTube(key=self.__api_key)
|
||||
|
||||
def unconfigure(self):
|
||||
self.__api_key = None
|
||||
self.__api = None
|
||||
|
||||
def validate_configuration(self, configuration: Dict[str, Any]):
|
||||
# TODO: implement
|
||||
pass
|
||||
|
Reference in New Issue
Block a user