{% set fallback_img = "data:image/svg+xml," %} {% macro card_generic(link, thumbnail, title='', badge=None) -%}
{% if badge is not none %} {{ badge | e }} {% endif %}
{{ title | e }}
{{ caller() }}
{%- endmacro %} {% macro card(video_id, title='', advanced_text='', pinned="undefined", advanced_title='', post_url=None, badge=None) -%} {% set caller_ = caller %} {% call card_generic("/watch?v="~video_id, "https://i.ytimg.com/vi/"~video_id~"/mqdefault.jpg", title, badge) %} {{ caller_() }}
{{ advanced_text }}
{% if post_url %} {{ emoji_link("comments", post_url, False) }} {%endif%} {% if pinned != "undefined" %} {{ emoji_button("pin", video_id, pinned, False) }} {{ emoji_button("hide", video_id, False, False) }} {%endif%} {{ emoji_link("audio", video_id, False) }} {{ emoji_link("raw", video_id, False) }} {{ emoji_link("json", video_id, False) }}
{% endcall %} {%- endmacro %} {% macro typed_card(params) -%} {% set c = params.content %} {% if params.type == 'VIDEO' %} {% call card(c.video_id, c.title, c.published, badge=c.length) %} {{ infobar_subscriptions(c.video_id, c.channel_id, c.author) }} {% endcall %} {% elif params.type == 'CHANNEL' %} {% call card_generic("/channel/"~c.channel_id~"/", c.icons[c.icons.largest] if 'icons' in c else '', c.title) %} Channel {{ c.subscribers }} {% endcall %} {% elif params.type == 'PLAYLIST' %} {% call card_generic("/playlist?list="~c.playlist_id, "https://i.ytimg.com/vi/"~c.video_id~"/mqdefault.jpg", c.title) %} {{ c.author }} {{ c.n_videos }} videos {% endcall %} {% elif params.type == 'WEBSITE' %} {% call card_generic(c.url, c.icons[c.icons.largest] if 'icons' in c else '', c.title) %} {{ c.domain }} {% endcall %} {% endif %} {%- endmacro %} {% macro dummycard() -%} {% for _ in range(4) %}
{% endfor %} {%- endmacro %} {% macro infobar_subscriptions(video_id, channel_id, author) -%} {% if channel_id is defined and channel_id is not none %} {{ author | e }} {% else %} {{ author | e }} {% endif %} {%- endmacro %} {% macro emoji_button(action, subject, reverse=False, text=False) -%} {% set icons = { 'pin': ['📌️', '📌️⃠'], 'hide': ['💨️', ''], 'subscribe': ['📝️', '🗑️'], } %} {% set texts = { 'pin': ['pin to subscription feed', 'unpin'], 'hide': ['hide video', ''], 'subscribe': ['subscribe', 'unsubscribe'], } %} {% set actions = { 'pin': 'youtube.feed_post', 'hide': 'youtube.feed_post', 'subscribe': 'youtube.manage_subscriptions', } %}
{%- endmacro %} {% macro emoji_link(action, subject, text=False) -%} {% set icons = { 'raw': '🎞️', 'json': '💡', 'audio': '🎧', 'comments': '💬', } %} {% set texts = { 'raw': 'show raw video', 'json': 'view json metadata', 'audio': 'listen to audio only', 'comments': 'view comments', } %} {% set actions = { 'raw': '/watch?v='~subject~'&show=raw', 'json': '/watch?v='~subject~'&show=json', 'audio': '/watch?v='~subject~'&show=audio', 'comments': 'https://old.reddit.com'~subject, } %} {# #}{{ icons[action] }}{# #}{{ texts[action] if text }} {%- endmacro %} {% macro pagination(text, fields, direction) -%} {%- endmacro %}