ytsm/app/YtManagerApp/services.py

32 lines
1.6 KiB
Python
Raw Normal View History

import dependency_injector.containers as containers
import dependency_injector.providers as providers
from dynamic_preferences.registries import global_preferences_registry
from YtManagerApp.management.appconfig import AppConfig
2020-04-10 21:30:24 +00:00
from YtManagerApp.management.download_manager import DownloadManager
from YtManagerApp.management.subscription_manager import SubscriptionManager
from YtManagerApp.management.video_manager import VideoManager
from YtManagerApp.management.video_provider_manager import VideoProviderManager
from YtManagerApp.management.youtube_dl_manager import YoutubeDlManager
from YtManagerApp.scheduler.scheduler import YtsmScheduler
2020-04-10 21:30:24 +00:00
class VideoProviders(containers.DeclarativeContainer):
from YtManagerApp.providers.ytapi_video_provider import YouTubeApiVideoProvider
2020-04-22 21:47:27 +00:00
from YtManagerApp.providers.dummy_video_provider import DummyVideoProvider
2020-04-10 21:30:24 +00:00
ytApiProvider = providers.Factory(YouTubeApiVideoProvider)
2020-04-22 21:47:27 +00:00
dummyProvider = providers.Factory(DummyVideoProvider)
2020-04-10 21:30:24 +00:00
class Services(containers.DeclarativeContainer):
globalPreferencesRegistry = providers.Object(global_preferences_registry.manager())
appConfig = providers.Singleton(AppConfig, globalPreferencesRegistry)
scheduler = providers.Singleton(YtsmScheduler, appConfig)
youtubeDLManager = providers.Singleton(YoutubeDlManager)
2020-04-10 21:30:24 +00:00
videoManager = providers.Singleton(VideoManager)
2020-04-22 21:47:27 +00:00
videoProviderManager = providers.Singleton(VideoProviderManager, [
VideoProviders.ytApiProvider(),
VideoProviders.dummyProvider(),
])
2020-04-10 21:30:24 +00:00
subscriptionManager = providers.Singleton(SubscriptionManager)
downloadManager = providers.Singleton(DownloadManager)