Some fixes
authorsaksham1115 <saksham115@gmail.com>
Tue, 2 Aug 2016 21:31:59 +0000 (21:31 +0000)
committersaksham1115 <saksham115@gmail.com>
Tue, 2 Aug 2016 21:31:59 +0000 (21:31 +0000)
mediagoblin/plugins/subtitles/tools.py
mediagoblin/plugins/subtitles/views.py

index f947ba92d0efb9ac13c90b9b9da348143f1cbaa0..d9a5cb381165427ccc24b07787aac6e3f01154bf 100644 (file)
@@ -25,11 +25,11 @@ def open_subtitle(path):
     subtitle_public_filepath = get_path(path)
     with mg_globals.public_store.get_file(
             subtitle_public_filepath, 'rb') as subtitle_public_file:
-            text = subtitle_public_file.read().decode('utf-8')
+            text = subtitle_public_file.read().decode('utf-8','ignore')
             return text
 
 def save_subtitle(path,text):
     subtitle_public_filepath = get_path(path)
     with mg_globals.public_store.get_file(
             subtitle_public_filepath, 'wb') as subtitle_public_file:
-        subtitle_public_file.write(text)
\ No newline at end of file
+        subtitle_public_file.write(text)
index b9d82ef309cb6f6b92bbd466ec23fbe61ff647a6..9bab6ce6274bdbf61c6f4b2e46441622ca42cc9b 100644 (file)
@@ -46,7 +46,7 @@ UNSAFE_MIMETYPES = [
 @require_active_login
 def edit_subtitles(request, media):
     allowed_extensions = ['aqt','gsub','jss','sub','ttxt','pjs','psb',
-                        'rt','smi','stl','ssf','srt','ssa','ass','usf','vtt','lrc']
+                        'rt','smi','rst','stl','ssf','srt','ssa','ass','usf','vtt','lrc']
     form = forms.EditSubtitlesForm(request.form)
 
     # Add any subtitles
@@ -69,7 +69,7 @@ def edit_subtitles(request, media):
 
             return redirect(request,
                             location=media.url_for_self(request.urlgen))
-        elif filepath.split('.')[:-1] not in allowed_extensions :
+        elif filepath.split('.')[-1] not in allowed_extensions :
             messages.add_message(
             request,
             messages.ERROR,
@@ -163,4 +163,4 @@ def delete_subtitles(request,media):
         ("Subtitle file deleted!!!"))
 
     return redirect(request,
-                        location=media.url_for_self(request.urlgen))
\ No newline at end of file
+                        location=media.url_for_self(request.urlgen))