How to use the ytcc.exceptions.YtccException function in ytcc

To help you get started, we’ve selected a few ytcc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github woefe / ytcc / ytcc / exceptions.py View on Github external
"""Raised when a given URL does not refer to a YouTube channel."""


class DuplicateChannelException(YtccException):
    """Raised when trying to subscribe to a channel the second (or more) time."""


class ChannelDoesNotExistException(YtccException):
    """Raised when the url of a given channel does not exist."""


class InvalidSubscriptionFileError(YtccException):
    """Raised when the given file is not a valid XML file."""


class BadConfigException(YtccException):
    """Raised when error in config file is encountered."""

class DatabaseOperationalError(YtccException):
    """Raised when database is locked and no operations can be performed.
github woefe / ytcc / ytcc / core.py View on Github external
:return: False if the given video_id does not exist or the player closed with a non-zero
         exit code. True if the video was played successfully.
        """
        no_video_flag = []
        if audio_only:
            no_video_flag.append("--no-video")

        if video:
            try:
                command = [
                    "mpv", *no_video_flag, *self.config.mpv_flags,
                    self.get_youtube_video_url(video.yt_videoid)
                ]
                subprocess.run(command, check=True)
            except FileNotFoundError:
                raise YtccException("Could not locate the mpv video player!")
            except subprocess.CalledProcessError:
                return False

            video.watched = True
            return True

        return False
github woefe / ytcc / ytcc / exceptions.py View on Github external
#
# ytcc 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 ytcc.  If not, see .

"""Exceptions in their own module to avoid circular imports."""

class YtccException(Exception):
    """A general parent class of all Exceptions that are used in Ytcc."""


class BadURLException(YtccException):
    """Raised when a given URL does not refer to a YouTube channel."""


class DuplicateChannelException(YtccException):
    """Raised when trying to subscribe to a channel the second (or more) time."""


class ChannelDoesNotExistException(YtccException):
    """Raised when the url of a given channel does not exist."""


class InvalidSubscriptionFileError(YtccException):
    """Raised when the given file is not a valid XML file."""


class BadConfigException(YtccException):
github woefe / ytcc / ytcc / exceptions.py View on Github external
"""Exceptions in their own module to avoid circular imports."""

class YtccException(Exception):
    """A general parent class of all Exceptions that are used in Ytcc."""


class BadURLException(YtccException):
    """Raised when a given URL does not refer to a YouTube channel."""


class DuplicateChannelException(YtccException):
    """Raised when trying to subscribe to a channel the second (or more) time."""


class ChannelDoesNotExistException(YtccException):
    """Raised when the url of a given channel does not exist."""


class InvalidSubscriptionFileError(YtccException):
    """Raised when the given file is not a valid XML file."""


class BadConfigException(YtccException):
    """Raised when error in config file is encountered."""

class DatabaseOperationalError(YtccException):
    """Raised when database is locked and no operations can be performed.
github woefe / ytcc / ytcc / core.py View on Github external
def get_youtube_video_url(yt_videoid: Optional[str]) -> str:
        """Return the YouTube URL for the given youtube video ID.

        :param yt_videoid:  The YouTube video ID.
        :return: The YouTube URL for the given youtube video ID.
        """
        if yt_videoid is None:
            raise YtccException("Video id is none!")

        return f"https://www.youtube.com/watch?v={yt_videoid}"
github woefe / ytcc / ytcc / exceptions.py View on Github external
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ytcc.  If not, see .

"""Exceptions in their own module to avoid circular imports."""

class YtccException(Exception):
    """A general parent class of all Exceptions that are used in Ytcc."""


class BadURLException(YtccException):
    """Raised when a given URL does not refer to a YouTube channel."""


class DuplicateChannelException(YtccException):
    """Raised when trying to subscribe to a channel the second (or more) time."""


class ChannelDoesNotExistException(YtccException):
    """Raised when the url of a given channel does not exist."""


class InvalidSubscriptionFileError(YtccException):
    """Raised when the given file is not a valid XML file."""


class BadConfigException(YtccException):
    """Raised when error in config file is encountered."""

class DatabaseOperationalError(YtccException):
    """Raised when database is locked and no operations can be performed.
github woefe / ytcc / ytcc / exceptions.py View on Github external
class DuplicateChannelException(YtccException):
    """Raised when trying to subscribe to a channel the second (or more) time."""


class ChannelDoesNotExistException(YtccException):
    """Raised when the url of a given channel does not exist."""


class InvalidSubscriptionFileError(YtccException):
    """Raised when the given file is not a valid XML file."""


class BadConfigException(YtccException):
    """Raised when error in config file is encountered."""

class DatabaseOperationalError(YtccException):
    """Raised when database is locked and no operations can be performed.
github woefe / ytcc / ytcc / exceptions.py View on Github external
"""A general parent class of all Exceptions that are used in Ytcc."""


class BadURLException(YtccException):
    """Raised when a given URL does not refer to a YouTube channel."""


class DuplicateChannelException(YtccException):
    """Raised when trying to subscribe to a channel the second (or more) time."""


class ChannelDoesNotExistException(YtccException):
    """Raised when the url of a given channel does not exist."""


class InvalidSubscriptionFileError(YtccException):
    """Raised when the given file is not a valid XML file."""


class BadConfigException(YtccException):
    """Raised when error in config file is encountered."""

class DatabaseOperationalError(YtccException):
    """Raised when database is locked and no operations can be performed.