Use SuspiciousOperation Exception
This commit is contained in:
parent
bb53e78a8f
commit
062cfe8e86
|
@ -26,11 +26,4 @@ class DatabaseConnectionError(Exception):
|
||||||
'''
|
'''
|
||||||
Raised when parsing or initially connecting to a database.
|
Raised when parsing or initially connecting to a database.
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NoImageSourceException(Exception):
|
|
||||||
'''
|
|
||||||
Raised when images are requested from a source of a type that does not have any.
|
|
||||||
'''
|
|
||||||
pass
|
|
|
@ -8,12 +8,13 @@ from datetime import datetime, timedelta
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.core.exceptions import SuspiciousOperation
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from common.errors import NoFormatException, NoImageSourceException
|
from common.errors import NoFormatException
|
||||||
from common.utils import clean_filename
|
from common.utils import clean_filename
|
||||||
from .youtube import (get_media_info as get_youtube_media_info,
|
from .youtube import (get_media_info as get_youtube_media_info,
|
||||||
download_media as download_youtube_media,
|
download_media as download_youtube_media,
|
||||||
|
@ -491,7 +492,7 @@ class Source(models.Model):
|
||||||
@property
|
@property
|
||||||
def get_image_url(self):
|
def get_image_url(self):
|
||||||
if self.source_type == self.SOURCE_TYPE_YOUTUBE_PLAYLIST:
|
if self.source_type == self.SOURCE_TYPE_YOUTUBE_PLAYLIST:
|
||||||
raise NoImageSourceException('This source is a playlist so it doesn\'t have thumbnail.')
|
raise SuspiciousOperation('This source is a playlist so it doesn\'t have thumbnail.')
|
||||||
|
|
||||||
return get_youtube_channel_image_info(self.url)
|
return get_youtube_channel_image_info(self.url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue