From 316832830d3429a73f96f29be1982de8bfafd3ff Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 May 2022 10:52:30 +0100 Subject: [PATCH 1/6] Add semantic markup for podcasts --- webapp_podcast.py | 50 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/webapp_podcast.py b/webapp_podcast.py index 8c829ba99..c96e4b9af 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -149,12 +149,13 @@ def _html_podcast_soundbites(link_url: str, extension: str, if ctr > 0: soundbite_title += ' ' + str(ctr) podcast_str += \ + ' \n' + \ ' \n' + '\n \n' podcast_str += ' \n' ctr += 1 @@ -197,18 +198,22 @@ def html_podcast_episode(css_cache: {}, translate: {}, podcast_str += html_keyboard_navigation(text_mode_banner, {}, {}) podcast_str += '

\n' - podcast_str += '
\n' + podcast_str += \ + '
\n' podcast_str += '
\n' podcast_str += '
\n' - podcast_str += ' \n' + podcast_str += ' \n' + '" alt="" ' + get_broken_link_substitute() + '/>\n' else: podcast_str += ' \n' + '" alt="" ' + get_broken_link_substitute() + '/>\n' + podcast_str += ' \n' podcast_str += '
\n' podcast_str += '
\n' @@ -236,11 +241,12 @@ def html_podcast_episode(css_cache: {}, translate: {}, # podcast player widget podcast_str += \ + ' \n' + \ ' \n' + '\n \n \n' elif podcast_properties.get('linkMimeType'): if '/youtube' in podcast_properties['linkMimeType']: url = link_url.replace('/watch?v=', '/embed/') @@ -249,50 +255,60 @@ def html_podcast_episode(css_cache: {}, translate: {}, if '?utm_' in url: url = url.split('?utm_')[0] podcast_str += \ + ' \n' + \ " \n" + "allowfullscreen>\n \n \n" elif 'video' in podcast_properties['linkMimeType']: video_mime_type = podcast_properties['linkMimeType'] video_msg = 'Your browser does not support the video element.' podcast_str += \ + ' \n' + \ '
\n' + \ ' \n
\n' + translate[video_msg] + \ + '\n \n
\n' podcast_title = \ remove_html(html.unescape(urllib.parse.unquote_plus(newswire_item[0]))) if podcast_title: podcast_str += \ - '

\n' + '

\n' if newswire_item[4]: podcast_description = \ html.unescape(urllib.parse.unquote_plus(newswire_item[4])) podcast_description = safe_web_text(podcast_description) if podcast_description: - podcast_str += '

' + podcast_description + '

\n' + podcast_str += \ + '

' + \ + podcast_description + '

\n' # donate button if podcast_properties.get('funding'): if podcast_properties['funding'].get('url'): donate_url = podcast_properties['funding']['url'] podcast_str += \ - '

\n' + '

\n' if podcast_properties['categories']: - podcast_str += '

' tags_str = '' for tag in podcast_properties['categories']: - tag_link = '/users/' + nickname + '/tags/' + tag.replace('#', '') - tags_str += '' + tag + ' ' - podcast_str += tags_str.strip() + '

\n' + tag = tag.replace('#', '') + tag_link = '/users/' + nickname + '/tags/' + tag + tags_str += \ + '#' + \ + '' + tag + '' + \ + ' ' + podcast_str += '

' + tags_str.strip() + '

\n' podcast_str += _html_podcast_performers(podcast_properties) podcast_str += \ From 39bf9520036135be1bdd020d9e4d216f811815fa Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 May 2022 11:04:35 +0100 Subject: [PATCH 2/6] Semantic markup for social interactions on podcasts --- webapp_podcast.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp_podcast.py b/webapp_podcast.py index c96e4b9af..e0923b274 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -60,9 +60,10 @@ def _html_podcast_social_interactions(podcast_properties: {}, '?replyto=' + episode_post_url + actor_str + '" target="_blank" ' + \ 'rel="nofollow noopener noreferrer">💬 ' + \ translate['Leave a comment'] + '\n' + \ + ' \n' + \ ' ' + \ - translate['View comments'] + '\n' + \ + translate['View comments'] + '\n \n' + \ '\n' return podcast_str From 9897b67f21cecfebd274add26848ac3cd0dca8b5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 May 2022 12:55:16 +0100 Subject: [PATCH 3/6] Add transcript links to podcast screen --- translations/ar.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/el.json | 3 ++- translations/en.json | 3 ++- translations/es.json | 3 ++- translations/fr.json | 3 ++- translations/ga.json | 3 ++- translations/hi.json | 3 ++- translations/it.json | 3 ++- translations/ja.json | 3 ++- translations/ko.json | 3 ++- translations/ku.json | 3 ++- translations/nl.json | 3 ++- translations/oc.json | 3 ++- translations/pl.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/sw.json | 3 ++- translations/uk.json | 3 ++- translations/zh.json | 3 ++- webapp_podcast.py | 32 ++++++++++++++++++++++++++++++++ 23 files changed, 76 insertions(+), 22 deletions(-) diff --git a/translations/ar.json b/translations/ar.json index 316f805cb..159f6dc91 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -550,5 +550,6 @@ "Common emoji": "الرموز التعبيرية الشائعة", "Copy and paste into your text": "نسخ ولصق في النص الخاص بك", "shrug": "هز كتفيه", - "DM warning": "لا يتم تشفير الرسائل المباشرة من طرف إلى طرف. لا تشارك أي معلومات حساسة للغاية هنا." + "DM warning": "لا يتم تشفير الرسائل المباشرة من طرف إلى طرف. لا تشارك أي معلومات حساسة للغاية هنا.", + "Transcript": "نص" } diff --git a/translations/ca.json b/translations/ca.json index 7c43b1811..d0ccf9cdd 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -550,5 +550,6 @@ "Common emoji": "Emoji comú", "Copy and paste into your text": "Copia i enganxa al teu text", "shrug": "arronsar les espatlles", - "DM warning": "Els missatges directes no estan xifrats d'extrem a extrem. No compartiu cap informació molt sensible aquí." + "DM warning": "Els missatges directes no estan xifrats d'extrem a extrem. No compartiu cap informació molt sensible aquí.", + "Transcript": "Transcripció" } diff --git a/translations/cy.json b/translations/cy.json index 3edbda29b..28ffaaabe 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -550,5 +550,6 @@ "Common emoji": "Emoji cyffredin", "Copy and paste into your text": "Copïwch a gludwch i'ch testun", "shrug": "shrug", - "DM warning": "Nid yw negeseuon uniongyrchol wedi'u hamgryptio o'r dechrau i'r diwedd. Peidiwch â rhannu unrhyw wybodaeth hynod sensitif yma." + "DM warning": "Nid yw negeseuon uniongyrchol wedi'u hamgryptio o'r dechrau i'r diwedd. Peidiwch â rhannu unrhyw wybodaeth hynod sensitif yma.", + "Transcript": "Trawsgrifiad" } diff --git a/translations/de.json b/translations/de.json index 72ddd6237..bb948dd02 100644 --- a/translations/de.json +++ b/translations/de.json @@ -550,5 +550,6 @@ "Common emoji": "Gewöhnliches Emoji", "Copy and paste into your text": "Kopieren und in Ihren Text einfügen", "shrug": "zucken", - "DM warning": "Direktnachrichten sind nicht Ende-zu-Ende verschlüsselt. Geben Sie hier keine hochsensiblen Informationen weiter." + "DM warning": "Direktnachrichten sind nicht Ende-zu-Ende verschlüsselt. Geben Sie hier keine hochsensiblen Informationen weiter.", + "Transcript": "Abschrift" } diff --git a/translations/el.json b/translations/el.json index f9403273a..f047d5f48 100644 --- a/translations/el.json +++ b/translations/el.json @@ -550,5 +550,6 @@ "Common emoji": "Κοινά emoji", "Copy and paste into your text": "Αντιγράψτε και επικολλήστε στο κείμενό σας", "shrug": "σήκωμα των ώμων", - "DM warning": "Τα άμεσα μηνύματα δεν είναι κρυπτογραφημένα από άκρο σε άκρο. Μην μοιράζεστε καμία εξαιρετικά ευαίσθητη πληροφορία εδώ." + "DM warning": "Τα άμεσα μηνύματα δεν είναι κρυπτογραφημένα από άκρο σε άκρο. Μην μοιράζεστε καμία εξαιρετικά ευαίσθητη πληροφορία εδώ.", + "Transcript": "Αντίγραφο" } diff --git a/translations/en.json b/translations/en.json index 1c52b2c36..39e83c326 100644 --- a/translations/en.json +++ b/translations/en.json @@ -550,5 +550,6 @@ "Common emoji": "Common emoji", "Copy and paste into your text": "Copy and paste into your text", "shrug": "shrug", - "DM warning": "Direct messages are not end-to-end encrypted. Do not share any highly sensitive information here." + "DM warning": "Direct messages are not end-to-end encrypted. Do not share any highly sensitive information here.", + "Transcript": "Transcript" } diff --git a/translations/es.json b/translations/es.json index badd6643b..1ff495947 100644 --- a/translations/es.json +++ b/translations/es.json @@ -550,5 +550,6 @@ "Common emoji": "Emoticonos comunes", "Copy and paste into your text": "Copia y pega en tu texto", "shrug": "encogimiento de hombros", - "DM warning": "Los mensajes directos no están cifrados de extremo a extremo. No comparta ninguna información altamente confidencial aquí." + "DM warning": "Los mensajes directos no están cifrados de extremo a extremo. No comparta ninguna información altamente confidencial aquí.", + "Transcript": "Transcripción" } diff --git a/translations/fr.json b/translations/fr.json index 3d18080eb..f0b090a63 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -550,5 +550,6 @@ "Common emoji": "Émoji commun", "Copy and paste into your text": "Copiez et collez dans votre texte", "shrug": "hausser les épaules", - "DM warning": "Les messages directs ne sont pas chiffrés de bout en bout. Ne partagez aucune information hautement sensible ici." + "DM warning": "Les messages directs ne sont pas chiffrés de bout en bout. Ne partagez aucune information hautement sensible ici.", + "Transcript": "Transcription" } diff --git a/translations/ga.json b/translations/ga.json index e2ed6b151..435eb4e37 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -550,5 +550,6 @@ "Common emoji": "Emoji coitianta", "Copy and paste into your text": "Cóipeáil agus greamaigh isteach i do théacs", "shrug": "shrug", - "DM warning": "Níl teachtaireachtaí díreacha criptithe ó cheann go ceann. Ná roinn aon fhaisnéis an-íogair anseo." + "DM warning": "Níl teachtaireachtaí díreacha criptithe ó cheann go ceann. Ná roinn aon fhaisnéis an-íogair anseo.", + "Transcript": "Athscríbhinn" } diff --git a/translations/hi.json b/translations/hi.json index 6b1f6d516..0d6df3594 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -550,5 +550,6 @@ "Common emoji": "आम इमोजी", "Copy and paste into your text": "अपने टेक्स्ट में कॉपी और पेस्ट करें", "shrug": "कंधे उचकाने की क्रिया", - "DM warning": "डायरेक्ट मैसेज एंड-टू-एंड एन्क्रिप्टेड नहीं होते हैं। यहां कोई अति संवेदनशील जानकारी साझा न करें।" + "DM warning": "डायरेक्ट मैसेज एंड-टू-एंड एन्क्रिप्टेड नहीं होते हैं। यहां कोई अति संवेदनशील जानकारी साझा न करें।", + "Transcript": "प्रतिलिपि" } diff --git a/translations/it.json b/translations/it.json index 7c39da738..eaaad64ee 100644 --- a/translations/it.json +++ b/translations/it.json @@ -550,5 +550,6 @@ "Common emoji": "Emoji comuni", "Copy and paste into your text": "Copia e incolla nel tuo testo", "shrug": "scrollare le spalle", - "DM warning": "I messaggi diretti non sono crittografati end-to-end. Non condividere qui alcuna informazione altamente sensibile." + "DM warning": "I messaggi diretti non sono crittografati end-to-end. Non condividere qui alcuna informazione altamente sensibile.", + "Transcript": "Trascrizione" } diff --git a/translations/ja.json b/translations/ja.json index 58cd5b309..03cb6f3de 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -550,5 +550,6 @@ "Common emoji": "一般的な絵文字", "Copy and paste into your text": "コピーしてテキストに貼り付けます", "shrug": "肩をすくめる", - "DM warning": "ダイレクトメッセージはエンドツーエンドで暗号化されません。 ここでは機密性の高い情報を共有しないでください。" + "DM warning": "ダイレクトメッセージはエンドツーエンドで暗号化されません。 ここでは機密性の高い情報を共有しないでください。", + "Transcript": "トランスクリプト" } diff --git a/translations/ko.json b/translations/ko.json index 3ed678894..919e5be73 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -550,5 +550,6 @@ "Common emoji": "일반적인 이모티콘", "Copy and paste into your text": "텍스트에 복사하여 붙여넣기", "shrug": "어깨를 으쓱하다", - "DM warning": "다이렉트 메시지는 종단 간 암호화되지 않습니다. 여기에 매우 민감한 정보를 공유하지 마십시오." + "DM warning": "다이렉트 메시지는 종단 간 암호화되지 않습니다. 여기에 매우 민감한 정보를 공유하지 마십시오.", + "Transcript": "성적 증명서" } diff --git a/translations/ku.json b/translations/ku.json index b4ea2fe54..04a1764a6 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -550,5 +550,6 @@ "Common emoji": "Emojiyên hevpar", "Copy and paste into your text": "Di nivîsa xwe de kopî bikin û bixin", "shrug": "şuştin", - "DM warning": "Peyamên rasterast bi dawî-bi-dawî ne şîfrekirî ne. Li vir agahdariya pir hesas parve nekin." + "DM warning": "Peyamên rasterast bi dawî-bi-dawî ne şîfrekirî ne. Li vir agahdariya pir hesas parve nekin.", + "Transcript": "Transcript" } diff --git a/translations/nl.json b/translations/nl.json index dd34449b9..d37b1264b 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -550,5 +550,6 @@ "Common emoji": "Gemeenschappelijke emoji", "Copy and paste into your text": "Kopieer en plak in je tekst", "shrug": "schouderophalend", - "DM warning": "Directe berichten zijn niet end-to-end versleuteld. Deel hier geen zeer gevoelige informatie." + "DM warning": "Directe berichten zijn niet end-to-end versleuteld. Deel hier geen zeer gevoelige informatie.", + "Transcript": "Vertaling" } diff --git a/translations/oc.json b/translations/oc.json index 80a41d432..cfa7fc302 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -546,5 +546,6 @@ "Common emoji": "Common emoji", "Copy and paste into your text": "Copy and paste into your text", "shrug": "shrug", - "DM warning": "Direct messages are not end-to-end encrypted. Do not share any highly sensitive information here." + "DM warning": "Direct messages are not end-to-end encrypted. Do not share any highly sensitive information here.", + "Transcript": "Transcript" } diff --git a/translations/pl.json b/translations/pl.json index eea50ea01..9f12c12c3 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -550,5 +550,6 @@ "Common emoji": "Popularne emotikony", "Copy and paste into your text": "Skopiuj i wklej do swojego tekstu", "shrug": "wzruszać ramionami", - "DM warning": "Wiadomości na czacie nie są szyfrowane metodą end-to-end. Nie udostępniaj tutaj żadnych wysoce wrażliwych informacji." + "DM warning": "Wiadomości na czacie nie są szyfrowane metodą end-to-end. Nie udostępniaj tutaj żadnych wysoce wrażliwych informacji.", + "Transcript": "Transkrypcja" } diff --git a/translations/pt.json b/translations/pt.json index 6bdefd5f7..f0bae683b 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -550,5 +550,6 @@ "Common emoji": "Emoji comum", "Copy and paste into your text": "Copie e cole no seu texto", "shrug": "dar de ombros", - "DM warning": "As mensagens diretas não são criptografadas de ponta a ponta. Não compartilhe nenhuma informação altamente sensível aqui." + "DM warning": "As mensagens diretas não são criptografadas de ponta a ponta. Não compartilhe nenhuma informação altamente sensível aqui.", + "Transcript": "Transcrição" } diff --git a/translations/ru.json b/translations/ru.json index 2c61af7ce..0110c5ed5 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -550,5 +550,6 @@ "Common emoji": "Общие смайлики", "Copy and paste into your text": "Скопируйте и вставьте в свой текст", "shrug": "пожимание плечами", - "DM warning": "Прямые сообщения не подвергаются сквозному шифрованию. Не делитесь здесь особо конфиденциальной информацией." + "DM warning": "Прямые сообщения не подвергаются сквозному шифрованию. Не делитесь здесь особо конфиденциальной информацией.", + "Transcript": "Стенограмма" } diff --git a/translations/sw.json b/translations/sw.json index 8c506d04f..648e3d5ad 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -550,5 +550,6 @@ "Common emoji": "Emoji ya kawaida", "Copy and paste into your text": "Nakili na ubandike kwenye maandishi yako", "shrug": "piga mabega", - "DM warning": "Ujumbe wa moja kwa moja haujasimbwa kutoka mwisho hadi mwisho. Usishiriki maelezo yoyote nyeti sana hapa." + "DM warning": "Ujumbe wa moja kwa moja haujasimbwa kutoka mwisho hadi mwisho. Usishiriki maelezo yoyote nyeti sana hapa.", + "Transcript": "Nakala" } diff --git a/translations/uk.json b/translations/uk.json index e792f13a9..3281dbcf5 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -550,5 +550,6 @@ "Common emoji": "Звичайні емодзі", "Copy and paste into your text": "Скопіюйте та вставте у свій текст", "shrug": "знизати плечима", - "DM warning": "Прямі повідомлення не наскрізне шифруються. Не публікуйте тут дуже конфіденційну інформацію." + "DM warning": "Прямі повідомлення не наскрізне шифруються. Не публікуйте тут дуже конфіденційну інформацію.", + "Transcript": "Стенограма" } diff --git a/translations/zh.json b/translations/zh.json index 5204eed11..ca7e34498 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -550,5 +550,6 @@ "Common emoji": "常见表情符号", "Copy and paste into your text": "复制并粘贴到您的文本中", "shrug": "耸耸肩", - "DM warning": "直接消息不是端到端加密的。 不要在这里分享任何高度敏感的信息。" + "DM warning": "直接消息不是端到端加密的。 不要在这里分享任何高度敏感的信息。", + "Transcript": "成绩单" } diff --git a/webapp_podcast.py b/webapp_podcast.py index e0923b274..db5be05a3 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -21,6 +21,35 @@ from webapp_utils import html_footer from webapp_utils import html_keyboard_navigation +def _html_podcast_transcripts(podcast_properties: {}, translate: {}) -> str: + """Returns html for transcripts of a podcast + """ + if not podcast_properties: + return '' + key = 'transcripts' + if not podcast_properties.get(key): + return '' + ctr = 1 + html_str = '' + for transcript in podcast_properties[key]: + transcript_url = None + if podcast_properties[key].get('url'): + transcript_url = podcast_properties[key]['url'] + elif podcast_properties[key].get('uri'): + transcript_url = podcast_properties[key]['uri'] + if not transcript_url: + continue + if ctr > 1: + html_str += '
' + html_str += '' + html_str += translate['Transcript'] + if ctr > 1: + html_str += ' ' + str(ctr) + html_str += '\n' + ctr += 1 + return html_str + + def _html_podcast_social_interactions(podcast_properties: {}, translate: {}, nickname: str) -> str: @@ -282,6 +311,9 @@ def html_podcast_episode(css_cache: {}, translate: {}, '' + \ podcast_title + \ '

\n' + transcripts = _html_podcast_transcripts(podcast_properties, translate) + if transcripts: + podcast_str += '

' + transcripts + '

\n' if newswire_item[4]: podcast_description = \ html.unescape(urllib.parse.unquote_plus(newswire_item[4])) From c267c5f66baa15c0bd987309aacf7f9c87793fc7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 May 2022 17:38:16 +0100 Subject: [PATCH 4/6] Include chapters on podcast screen --- daemon.py | 7 ++- newswire.py | 1 + webapp_podcast.py | 119 ++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 118 insertions(+), 9 deletions(-) diff --git a/daemon.py b/daemon.py index 1a53f123a..f9bc25a87 100644 --- a/daemon.py +++ b/daemon.py @@ -15626,7 +15626,12 @@ class PubServer(BaseHTTPRequestHandler): self.server.theme_name, self.server.default_timeline, self.server.text_mode_banner, - self.server.access_keys) + self.server.access_keys, + self.server.session, + self.server.session_onion, + self.server.session_i2p, + self.server.http_prefix, + self.server.debug) if html_str: msg = html_str.encode('utf-8') msglen = len(msg) diff --git a/newswire.py b/newswire.py index f554fe657..db20b0956 100644 --- a/newswire.py +++ b/newswire.py @@ -515,6 +515,7 @@ def xml_podcast_to_dict(base_dir: str, xml_item: str, xml_str: str) -> {}: "transcripts": [], "valueRecipients": [], "trailers": [], + "chapters": [], "discussion": [], "episode": '', "socialInteract": [], diff --git a/webapp_podcast.py b/webapp_podcast.py index db5be05a3..a10b2b03e 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -9,6 +9,7 @@ __module_group__ = "Web Interface Columns" import os import html +import datetime import urllib.parse from shutil import copyfile from utils import get_config_param @@ -19,6 +20,88 @@ from webapp_utils import get_broken_link_substitute from webapp_utils import html_header_with_external_style from webapp_utils import html_footer from webapp_utils import html_keyboard_navigation +from session import get_json + + +def _html_podcast_chapters(link_url: str, + session, session_onion, session_i2p, + http_prefix: str, domain: str, + podcast_properties: {}, translate: {}, + debug: bool) -> str: + """Returns html for chapters of a podcast + """ + if not podcast_properties: + return '' + key = 'chapters' + if not podcast_properties.get(key): + return '' + if not isinstance(podcast_properties[key], dict): + return '' + if podcast_properties[key].get('url'): + chapters_url = podcast_properties[key]['url'] + elif podcast_properties[key].get('uri'): + chapters_url = podcast_properties[key]['uri'] + else: + return '' + html_str = '' + if podcast_properties[key].get('type'): + url_type = podcast_properties[key]['type'] + + curr_session = session + if chapters_url.endswith('.onion'): + curr_session = session_onion + elif chapters_url.endswith('.i2p'): + curr_session = session_i2p + + as_header = { + 'Accept': url_type + } + + if 'json' in url_type: + chapters_json = \ + get_json(None, curr_session, chapters_url, + as_header, None, debug, __version__, + http_prefix, domain) + if not chapters_json: + return '' + if not chapters_json.get('chapters'): + return '' + if not isinstance(chapters_json['chapters'], list): + return '' + chapters_html = '' + for chapter in chapters_json['chapters']: + if not isinstance(chapter, dict): + continue + if not chapter.get('title'): + continue + if not chapter.get('startTime'): + continue + chapter_title = chapter['title'] + chapter_url = '' + if chapter.get('url'): + chapter_url = chapter['url'] + chapter_title = \ + '' + \ + chapter['title'] + '<\a>' + start_sec = chapter['startTime'] + skip_url = link_url + '#t=' + str(start_sec) + start_time_str = \ + '' + \ + str(datetime.timedelta(seconds=start_sec)) + \ + '' + if chapter.get('img'): + chapters_html += \ + '
  • \n' + \ + ' ' + start_time_str + '\n' + \ + ' \n' + \ + ' ' + chapter_title + '\n' + \ + '
  • \n' + if chapters_html: + html_str = '
      \n' + chapters_html + '
    \n' + return html_str def _html_podcast_transcripts(podcast_properties: {}, translate: {}) -> str: @@ -29,6 +112,8 @@ def _html_podcast_transcripts(podcast_properties: {}, translate: {}) -> str: key = 'transcripts' if not podcast_properties.get(key): return '' + if not isinstance(podcast_properties[key], list): + return '' ctr = 1 html_str = '' for transcript in podcast_properties[key]: @@ -62,6 +147,8 @@ def _html_podcast_social_interactions(podcast_properties: {}, key = 'socialInteract' if not podcast_properties.get(key): return '' + if not isinstance(podcast_properties[key], dict): + return '' if podcast_properties[key].get('uri'): episode_post_url = podcast_properties[key]['uri'] elif podcast_properties[key].get('url'): @@ -102,21 +189,27 @@ def _html_podcast_performers(podcast_properties: {}) -> str: """ if not podcast_properties: return '' - if not podcast_properties.get('persons'): + key = 'persons' + if not podcast_properties.get(key): + return '' + if not isinstance(podcast_properties[key], list): return '' # list of performers podcast_str = '
    \n' podcast_str += '
    \n' podcast_str += '\n' @@ -198,7 +294,9 @@ def html_podcast_episode(css_cache: {}, translate: {}, base_dir: str, nickname: str, domain: str, newswire_item: [], theme: str, default_timeline: str, - text_mode_banner: str, access_keys: {}) -> str: + text_mode_banner: str, access_keys: {}, + session, session_onion, session_i2p, + http_prefix: str, debug: bool) -> str: """Returns html for a podcast episode, giebn an item from the newswire """ css_filename = base_dir + '/epicyon-podcast.css' @@ -347,6 +445,11 @@ def html_podcast_episode(css_cache: {}, translate: {}, podcast_str += \ _html_podcast_social_interactions(podcast_properties, translate, nickname) + podcast_str += \ + _html_podcast_chapters(link_url, + session, session_onion, session_i2p, + http_prefix, domain, + podcast_properties, translate, debug) podcast_str += '
    \n' podcast_str += '
    \n' From d00180e456ec5cb997f0c9ba73d0fb2616547909 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 May 2022 17:57:30 +0100 Subject: [PATCH 5/6] Chapters image size --- epicyon-podcast.css | 9 +++++++++ webapp_podcast.py | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/epicyon-podcast.css b/epicyon-podcast.css index 87c22d227..533c9a7dd 100644 --- a/epicyon-podcast.css +++ b/epicyon-podcast.css @@ -233,6 +233,9 @@ a:focus { padding: 10px; margin: 20px 30px; } + .chapters img { + width: 10%; + } } @media screen and (max-width: 1000px) { @@ -310,6 +313,9 @@ a:focus { padding: 20px; margin: 30px 40px; } + .chapters img { + width: 15%; + } } @media screen and (max-width: 480px) { @@ -387,4 +393,7 @@ a:focus { padding: 20px; margin: 30px 40px; } + .chapters img { + width: 15%; + } } diff --git a/webapp_podcast.py b/webapp_podcast.py index a10b2b03e..526cb259b 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -96,11 +96,12 @@ def _html_podcast_chapters(link_url: str, ' \n' + \ + '" alt="" />\n' + \ ' ' + chapter_title + '\n' + \ ' \n' if chapters_html: - html_str = '
      \n' + chapters_html + '
    \n' + html_str = \ + '
      \n' + chapters_html + '
    \n' return html_str From c6b0387cc8d1763cfcc54e74952319ff8ec293fb Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 May 2022 18:11:25 +0100 Subject: [PATCH 6/6] Styling for performer images on podcast screen --- epicyon-podcast.css | 13 +++++++++++++ webapp_podcast.py | 13 +++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/epicyon-podcast.css b/epicyon-podcast.css index 533c9a7dd..32dd9d3e5 100644 --- a/epicyon-podcast.css +++ b/epicyon-podcast.css @@ -158,6 +158,10 @@ a:focus { width: 15%; } +.performers { + display: flex; +} + @media screen and (min-width: 400px) { textarea { font-family: Arial, Helvetica, sans-serif; @@ -233,6 +237,9 @@ a:focus { padding: 10px; margin: 20px 30px; } + .performers img { + width: 20%; + } .chapters img { width: 10%; } @@ -313,6 +320,9 @@ a:focus { padding: 20px; margin: 30px 40px; } + .performers img { + width: 30%; + } .chapters img { width: 15%; } @@ -393,6 +403,9 @@ a:focus { padding: 20px; margin: 30px 40px; } + .performers img { + width: 30%; + } .chapters img { width: 15%; } diff --git a/webapp_podcast.py b/webapp_podcast.py index 526cb259b..732e252c9 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -91,17 +91,18 @@ def _html_podcast_chapters(link_url: str, '' if chapter.get('img'): chapters_html += \ - '
  • \n' + \ - ' ' + start_time_str + '\n' + \ - ' \n' + \ + ' ' + start_time_str + '\n' + \ + ' \n' + \ - ' ' + chapter_title + '\n' + \ - '
  • \n' + ' ' + chapter_title + '\n' + \ + ' \n' if chapters_html: html_str = \ - '
      \n' + chapters_html + '
    \n' + '
    \n' + \ + '
      \n' + chapters_html + '
    \n
    \n' return html_str