import os

from django import template 

register = template.Library()


def srt_path(value): 
    if value is None:
        return {}

    STATIC_FILES = 'subtitles/srt'
    if "mp4" in value:

  

        return os.path.join(STATIC_FILES, f"{(os.path.splitext(os.path.basename(value))[0]).split('.')[0]}.srt")
    return os.path.join(STATIC_FILES, f"{os.path.splitext(os.path.basename(value))[0]}.srt")
    
register.filter('srt_path', srt_path) 
