<commit_before>from django import template
from django.utils.safestring import mark_safe
from mygpo.data import youtube

register = template.Library()

@register.filter
def is_youtube_video(url):
    return youtube.is_video_link(url)

@register.filter
def get_youtube_id(url):
    return youtube.get_youtube_id(url)

@register.filter
def embed_youtube_video(episode, user):

    s = """embedYoutubeVideo("%s", "%s", "%s", "%s");""" % \
         (youtube.get_youtube_id(episode.url), user.username, episode.podcast.url, episode.url)

    return mark_safe(s)
<commit_msg>add workaround for bug in embed_youtube_video<commit_after>from django import template
from django.utils.safestring import mark_safe
from mygpo.core.models import Podcast
from mygpo.data import youtube

register = template.Library()

@register.filter
def is_youtube_video(url):
    return youtube.is_video_link(url)

@register.filter
def get_youtube_id(url):
    return youtube.get_youtube_id(url)

@register.filter
def embed_youtube_video(episode, user):
    #TODO: refactor to template tag and pass podcast as parameter
    podcast = Podcast.get(episode.podcast)
    s = """embedYoutubeVideo("%s", "%s", "%s", "%s");""" % \
         (youtube.get_youtube_id(episode.url), user.username, podcast.url, episode.url)

    return mark_safe(s)

{'fraction_non_alphanumeric': 0.11926605504587157, 'fraction_numerical': 0.0, 'mean_word_length': 5.145539906103286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4648639', 'n_tokens_mistral': 443, 'n_tokens_neox': 420, 'n_words': 99}