##// END OF EJS Templates
Added support for youtu.be links. Show file size when size validation failed
neko259 -
r1433:8bc8ced0 default
parent child Browse files
Show More
@@ -356,8 +356,7 b' class PostForm(NeboardForm):'
356 except forms.ValidationError as e:
356 except forms.ValidationError as e:
357 raise e
357 raise e
358 except Exception as e:
358 except Exception as e:
359 # Just return no file
359 raise forms.ValidationError(e)
360 pass
361
360
362 def _validate_hash(self, timestamp: str, iteration: str, guess: str, message: str):
361 def _validate_hash(self, timestamp: str, iteration: str, guess: str, message: str):
363 post_time = timezone.datetime.fromtimestamp(
362 post_time = timezone.datetime.fromtimestamp(
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -488,8 +488,8 b' msgstr "\xd0\x9e\xd0\xba"'
488
488
489 #: utils.py:120
489 #: utils.py:120
490 #, python-format
490 #, python-format
491 msgid "File must be less than %s bytes"
491 msgid "File must be less than %s but is %s."
492 msgstr "Файл должен быть менее %s байт"
492 msgstr "Файл должен быть менее %s, но его размер %s."
493
493
494 msgid "Please wait %(delay)d second before sending message"
494 msgid "Please wait %(delay)d second before sending message"
495 msgid_plural "Please wait %(delay)d seconds before sending message"
495 msgid_plural "Please wait %(delay)d seconds before sending message"
@@ -17,7 +17,7 b" HEADER_CONTENT_TYPE = 'content-type'"
17
17
18 FILE_DOWNLOAD_CHUNK_BYTES = 200000
18 FILE_DOWNLOAD_CHUNK_BYTES = 200000
19
19
20 YOUTUBE_URL = re.compile(r'https?://www\.youtube\.com/watch\?v=\w+')
20 YOUTUBE_URL = re.compile(r'https?://(www\.youtube\.com/watch\?v=|youtu.be/)\w+')
21
21
22
22
23 class Downloader:
23 class Downloader:
@@ -9,6 +9,7 b' import hmac'
9 from django.core.cache import cache
9 from django.core.cache import cache
10 from django.db.models import Model
10 from django.db.models import Model
11 from django import forms
11 from django import forms
12 from django.template.defaultfilters import filesizeformat
12 from django.utils import timezone
13 from django.utils import timezone
13 from django.utils.translation import ugettext_lazy as _
14 from django.utils.translation import ugettext_lazy as _
14 import magic
15 import magic
@@ -118,8 +119,8 b' def validate_file_size(size: int):'
118 max_size = boards.settings.get_int('Forms', 'MaxFileSize')
119 max_size = boards.settings.get_int('Forms', 'MaxFileSize')
119 if size > max_size:
120 if size > max_size:
120 raise forms.ValidationError(
121 raise forms.ValidationError(
121 _('File must be less than %s bytes')
122 _('File must be less than %s but is %s.')
122 % str(max_size))
123 % (filesizeformat(max_size), filesizeformat(size)))
123
124
124
125
125 def get_extension(filename):
126 def get_extension(filename):
General Comments 0
You need to be logged in to leave comments. Login now