Opening ths subtitle using absolute path and open function
This commit is contained in:
parent
2c36555bfe
commit
316bef6908
@ -580,13 +580,14 @@ def edit_metadata(request, media):
|
|||||||
'media':media})
|
'media':media})
|
||||||
|
|
||||||
|
|
||||||
from mediagoblin.tools.subtitles import get_path
|
from mediagoblin.tools.subtitles import open_subtitle
|
||||||
|
|
||||||
@require_active_login
|
@require_active_login
|
||||||
@path_subtitle
|
@path_subtitle
|
||||||
def custom_subtitles(request,path=None):
|
def custom_subtitles(request,path=None):
|
||||||
form = forms.CustomizeSubtitlesForm(request.form)
|
text = open_subtitle(path)
|
||||||
path = get_path(path)
|
form = forms.CustomizeSubtitlesForm(request.form,
|
||||||
|
subtitle=text)
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
request,
|
request,
|
||||||
"mediagoblin/edit/custom_subtitles.html",
|
"mediagoblin/edit/custom_subtitles.html",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ast
|
import ast,os
|
||||||
|
|
||||||
def get_path(path):
|
def get_path(path):
|
||||||
"""
|
"""
|
||||||
@ -8,3 +8,19 @@ def get_path(path):
|
|||||||
x = ["A", "B", "C", "D"]
|
x = ["A", "B", "C", "D"]
|
||||||
"""
|
"""
|
||||||
return ast.literal_eval(path)
|
return ast.literal_eval(path)
|
||||||
|
|
||||||
|
def open_subtitle(path):
|
||||||
|
temp = ['user_dev','media','public']
|
||||||
|
path = list(get_path(path))
|
||||||
|
file_path = os.path.abspath(__file__).split('/') # Path of current file as dictionary
|
||||||
|
"""
|
||||||
|
Creating the absolute path for the subtitle file
|
||||||
|
"""
|
||||||
|
subtitle_path = file_path[:-3] + temp + path
|
||||||
|
subtitle_path = "/" + os.path.join(*subtitle_path)
|
||||||
|
"""
|
||||||
|
Opening the file using the absolute path
|
||||||
|
"""
|
||||||
|
subtitle = open(subtitle_path,"r")
|
||||||
|
text = subtitle.read()
|
||||||
|
return text
|
Loading…
x
Reference in New Issue
Block a user