Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Forces extensions in settings not to have leading dot.

get_poster_url to get the image url (not working)
  • Loading branch information...
commit f79852bbbb8a891c9f2d042b9cf851aa99aaf047 1 parent 53382b8
@nmfm authored
View
11 filer/fields/multistorage_file.py
@@ -37,10 +37,7 @@ class FormatNameMixin(object):
def get_format_name(self, ext):
path, source_filename = os.path.split(self.name)
filename, extension = os.path.splitext(source_filename)
- if ext.startswith('.'):
- newfilename = '%s%s' % (filename, ext)
- else:
- newfilename = '%s.%s' % (filename, ext)
+ newfilename = '%s.%s' % (filename, ext)
return os.path.join(path, newfilename)
def get_format_url(self, ext):
@@ -50,6 +47,12 @@ def get_format_url(self, ext):
else:
raise NameError
+ def get_poster_url(self):
+ original_path = self.formats_storage.path(self.name)
+ original_path, filename = os.path.split(original_path)
+ basename = os.path.splitext(filename)[0]
+ return os.path.join(original_path, basename + '.png')
+
class MultiStorageFieldFile(ThumbnailerNameMixin,
easy_thumbnails_files.ThumbnailerFieldFile,
View
29 filer/models/videomodels.py
@@ -36,7 +36,7 @@ class Video(File):
@classmethod
def matches_file_type(cls, iname, ifile, request):
- iext = os.path.splitext(iname)[1].lower()
+ iext = os.path.splitext(iname)[1].lower().lstrip('.')
return iext in filer_settings.FILER_SOURCE_VIDEO_FORMATS
@property
@@ -61,14 +61,20 @@ def _check_validity(self):
def formats(self):
_formats = {}
for ext in filer_settings.FILER_VIDEO_FORMATS:
- if ext.startswith('.'):
- ext = ext[1:]
try:
_formats[ext] = self.file.get_format_url(ext)
except Exception, e:
pass
return _formats
+ @property
+ def poster(self):
+ try:
+ return self.file.get_poster_url()
+ except Exception, e:
+ return ""
+
+
def convert(self):
original_path = self.file.storage.path(self.file.name)
path = os.path.split(self.file.format_storage.path(self.file.name))[0]
@@ -89,17 +95,6 @@ class Meta:
verbose_name = _('video')
verbose_name_plural = _('videos')
- def get_video_flv_url(self):
- return self.file.formats_storage.url(self.flv())
-
- def flv(self):
- path = self.file.name
- path, filename = os.path.split(path) #os.path.dirname(kwargs['file'].path_full)
- basename = os.path.splitext(filename)[0]
- return os.path.join(path, basename + '.flv')
-
-def thumbnail_path(self):
- original_path = self.formats_storage.path(self.name)
- original_path, filename = os.path.split(original_path) #os.path.dirname(kwargs['file'].path_full)
- basename = os.path.splitext(filename)[0]
- return os.path.join(original_path, basename + '.png')
+ #def get_video_flv_url(self):
+ #return self.file.formats_storage.url(self.flv())
+
View
8 filer/settings.py
@@ -112,7 +112,7 @@
))
FILER_PRIVATEMEDIA_FORMATS_SERVER = getattr(settings, 'FILER_PRIVATEMEDIA_FORMATS_SERVER', DefaultServer())
-# formats recognized as video file formats
-FILER_SOURCE_VIDEO_FORMATS = ('.mp4', '.avi', '.wmv', '.mov', '.mpg')
-# formats to convert into
-FILER_VIDEO_FORMATS = ('.flv', '.mp4')
+# formats recognized as video file formats (no leading dot)
+FILER_SOURCE_VIDEO_FORMATS = ('mp4', 'avi', 'wmv', 'mov', 'mpg')
+# formats to convert into (no leading dot)
+FILER_VIDEO_FORMATS = ('flv', 'mp4')
View
2  filer/templates/image_filer/image.html
@@ -4,4 +4,4 @@
src="{{ image_publication.url }}" />
{% if image_publication.caption %}<span class="image_caption">{{ image_publication.caption }}</span>{% endif %}
{% if image_publication.show_author %}<span class="image_author">({% trans "author"|title %}: {{ image_publication.image.author }})</span>{% endif %}
-</span>
+</span>
View
4 filer/utils/video.py
@@ -10,9 +10,7 @@ def convert_video(sourcefile, path, extension):
if sourcefile is None:
return True, "Sourcefile does not exist"
filebase, original_ext = os.path.splitext(filename)
- if original_ext == extension:
- return False, "No need to convert, already a %s", extension
- convfilename = "%s%s" % (filebase, extension)
+ convfilename = "%s.%s" % (filebase, extension)
targetfile = os.path.join(path, convfilename)
if not os.path.exists(path):
os.makedirs(path)
Please sign in to comment.
Something went wrong with that request. Please try again.