# This file is part of stov, written by Helmut Pozimski 2012-2021. # # stov is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2 of the License. # # stov is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with stov. If not, see . # -*- coding: utf8 -*- """This module contains all custome exceptions used by stov.""" class DBConnectionFailedException(Exception): """ This exception will be raised when the initial connetion attempt to the database fails. """ def __init__(self): super(DBConnectionFailedException, self).__init__() self.__message = _("Could not access the database, please check path" " and permissions and try again!") def __str__(self): return self.__message class DBWriteAccessFailedException(Exception): """This exception will be raised when a write access to the database fails (e.g. when the database file permissions are set to read only). """ def __init__(self): super(DBWriteAccessFailedException, self).__init__() self.__message = _("Write access to the database failed, please check " "file permissions and the file system and try" " again!") def __str__(self): return self.__message class SubscriptionNotFoundException(Exception): """This exception will be raised when a requested subscription can't be found in the database """ def __init__(self): super(SubscriptionNotFoundException, self).__init__() self.__message = _("The subscription you requested could not be " "found in the database, requested action aborted.") def __str__(self): return self.__message class NoDataFromYoutubeAPIException(Exception): """This exception will be raised when the Connection to the youtube API failed or no data was returned """ def __init__(self): super(NoDataFromYoutubeAPIException, self).__init__() self.__message = _("The connection to the youtube API failed or " "no data was returned.") def __str__(self): return self.__message class YoutubeAPITimeoutException(Exception): """This exception will be raised when an API request times out""" def __init__(self, title): super(YoutubeAPITimeoutException, self).__init__() self.__message = _("The API Request timed out for subscription %s," "please try again later.") % title def __str__(self): return self.__message class ConfigFileWriteErrorException(Exception): """This exception will be raised when a write access to the configuration file fails. """ def __init__(self): super(ConfigFileWriteErrorException, self).__init__() self.__message = _("The configuration could not be written, please" " check that the configuration direcroty exists" " and is writable.") def __str__(self): return self.__message class DirectoryCreationFailedException(Exception): """This exception will be raised when the creation of a directory failed. """ def __init__(self): super(DirectoryCreationFailedException, self).__init__() self.__message = _("The directory could not be created, " "please check that the parent directory " "exists and is writable") def __str__(self): return self.__message class ConfigFileReadErrorException(Exception): """This exception will be raised when the configuration file couldn't be opened for reading """ def __init__(self): super(ConfigFileReadErrorException, self).__init__() self.__message = _("The configuration could not be read, please check " "that the configuration file exists and is " "readable.") def __str__(self): return self.__message class InvalidConfigurationVersionException(Exception): """This exception will be raised when an invalid configuration version is detected. """ def __init__(self): super(InvalidConfigurationVersionException, self).__init__() self.__message = _("Invalid config version read.") def __str__(self): return self.__message class SubscriptionDisabledException(Exception): """This exception will be raised when an exception is disabled and a requested action is not taken because of this fact. """ def __init__(self, subscription): super(SubscriptionDisabledException, self).__init__() self.__message = _("The subscription %s is disabled, videos will" " not be downloaded.") % subscription def __str__(self): return self.__message class DownloadDirectoryCreationFailedException(Exception): """This exception will be raised when the creation of a subscription directory to download a video failed. """ def __init__(self): super(DownloadDirectoryCreationFailedException, self).__init__() self.__message = _("The download directory does not exist and can't " "be created. Please check your configuration and " "try again.") def __str__(self): return self.__message class ConfigurationMigrationFailed(Exception): """This exception will be raised when the migration of the configuration to the json format fails. """ def __init__(self): super(ConfigurationMigrationFailed, self).__init__() self._message = _("The migration of the configuration to the json " "format failed.") def __str__(self): return self._message class YoutubeDlCallFailed(Exception): """This exception will be raised when a call to youtube-dl fails because of an error returned by youtube-dl. """ def __init__(self): super(YoutubeDlCallFailed, self).__init__() self._message = _("Execution of youtube-dl failed.") def __str__(self): return self._message class ChannelNotFound(Exception): """ Will be raised when a specific user or channel cannot be found on the site. """ def __init__(self): super(ChannelNotFound, self).__init__() self._message = _("Channel not found on video site") def __str__(self): return self._message class SiteUnsupported(Exception): """ Will be raised when stov is called for an unsupported site """ def __init__(self): super(SiteUnsupported, self).__init__() self._message = _("Error: This site is not (yet) supported by stov!") def __str__(self): return self._message class TypeNotSupported(Exception): """ Will be raised when a video site does not support a specific subscription type """ def __init__(self): super(TypeNotSupported, self).__init__() self._message = _("Error: This subscription type is not supported by " "the video site") def __str__(self): return self._message