mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
1631b9311b
2
blog.py
2
blog.py
|
@ -284,7 +284,7 @@ def _html_blog_post_content(debug: bool, session, authorized: bool,
|
|||
content_str = replace_emoji_from_tags(session, base_dir,
|
||||
content_str,
|
||||
post_json_object_tags,
|
||||
'content', debug)
|
||||
'content', debug, True)
|
||||
if article_added:
|
||||
blog_str += '<br>' + content_str + '</article>\n'
|
||||
else:
|
||||
|
|
21
content.py
21
content.py
|
@ -398,7 +398,7 @@ def _update_common_emoji(base_dir: str, emoji_content: str) -> None:
|
|||
|
||||
def replace_emoji_from_tags(session, base_dir: str,
|
||||
content: str, tag: [], message_type: str,
|
||||
debug: bool) -> str:
|
||||
debug: bool, screen_readable: bool) -> str:
|
||||
"""Uses the tags to replace :emoji: with html image markup
|
||||
"""
|
||||
for tag_item in tag:
|
||||
|
@ -429,8 +429,13 @@ def replace_emoji_from_tags(session, base_dir: str,
|
|||
replaced = False
|
||||
try:
|
||||
replace_char = chr(int("0x" + icon_name, 16))
|
||||
content = content.replace(tag_item['name'],
|
||||
replace_char)
|
||||
if not screen_readable:
|
||||
replace_char = \
|
||||
'<span aria-hidden="true">' + \
|
||||
replace_char + '</span>'
|
||||
content = \
|
||||
content.replace(tag_item['name'],
|
||||
replace_char)
|
||||
replaced = True
|
||||
except BaseException:
|
||||
if debug:
|
||||
|
@ -479,6 +484,10 @@ def replace_emoji_from_tags(session, base_dir: str,
|
|||
_update_common_emoji(base_dir,
|
||||
"0x" + icon_name)
|
||||
if icon_code_sequence:
|
||||
if not screen_readable:
|
||||
icon_code_sequence = \
|
||||
'<span aria-hidden="true">' + \
|
||||
icon_code_sequence + '</span>'
|
||||
content = content.replace(tag_item['name'],
|
||||
icon_code_sequence)
|
||||
|
||||
|
@ -487,8 +496,12 @@ def replace_emoji_from_tags(session, base_dir: str,
|
|||
html_class = 'emojiheader'
|
||||
if message_type == 'profile':
|
||||
html_class = 'emojiprofile'
|
||||
if screen_readable:
|
||||
emoji_tag_name = tag_item['name'].replace(':', '')
|
||||
else:
|
||||
emoji_tag_name = ''
|
||||
emoji_html = "<img src=\"" + tag_item['icon']['url'] + "\" alt=\"" + \
|
||||
tag_item['name'].replace(':', '') + \
|
||||
emoji_tag_name + \
|
||||
"\" align=\"middle\" class=\"" + html_class + "\"/>"
|
||||
content = content.replace(tag_item['name'], emoji_html)
|
||||
return content
|
||||
|
|
10
daemon.py
10
daemon.py
|
@ -18856,7 +18856,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.base_dir,
|
||||
fields['message'],
|
||||
tags, 'content',
|
||||
self.server.debug)
|
||||
self.server.debug,
|
||||
True)
|
||||
|
||||
post_json_object['object']['content'] = \
|
||||
fields['message']
|
||||
|
@ -20627,7 +20628,8 @@ def load_tokens(base_dir: str, tokens_dict: {}, tokens_lookup: {}) -> None:
|
|||
break
|
||||
|
||||
|
||||
def run_daemon(check_actor_timeout: int,
|
||||
def run_daemon(preferred_podcast_formats: [],
|
||||
check_actor_timeout: int,
|
||||
crawlers_allowed: [],
|
||||
dyslexic_font: bool,
|
||||
content_license_url: str,
|
||||
|
@ -20719,6 +20721,10 @@ def run_daemon(check_actor_timeout: int,
|
|||
# scan the theme directory for any svg files containing scripts
|
||||
assert not scan_themes_for_scripts(base_dir)
|
||||
|
||||
# list of preferred podcast formats
|
||||
# eg ['audio/opus', 'audio/mp3']
|
||||
httpd.preferred_podcast_formats = preferred_podcast_formats
|
||||
|
||||
# for each account, whether bold reading is enabled
|
||||
httpd.bold_reading = load_bold_reading(base_dir)
|
||||
|
||||
|
|
29
epicyon.py
29
epicyon.py
|
@ -267,6 +267,10 @@ parser.add_argument('--proxy', dest='proxy_port', type=int, default=None,
|
|||
parser.add_argument('--path', dest='base_dir',
|
||||
type=str, default=os.getcwd(),
|
||||
help='Directory in which to store posts')
|
||||
parser.add_argument('--podcast-formats', dest='podcast_formats',
|
||||
type=str, default=None,
|
||||
help='Preferred podcast formats separated by commas. ' +
|
||||
'eg. "opus, mp3"')
|
||||
parser.add_argument('--ytdomain', dest='yt_replace_domain',
|
||||
type=str, default=None,
|
||||
help='Domain used to replace youtube.com')
|
||||
|
@ -1138,10 +1142,30 @@ if args.domain:
|
|||
domain = args.domain
|
||||
set_config_param(base_dir, 'domain', domain)
|
||||
|
||||
# comma separated list of preferred audio formats. eg. "opus", "mp3"
|
||||
# in order of preference
|
||||
preferred_podcast_formats = ['ogg', 'mpeg', 'opus']
|
||||
if args.podcast_formats:
|
||||
podcast_formats_str = args.podcast_formats
|
||||
else:
|
||||
podcast_formats_str = \
|
||||
get_config_param(base_dir, 'preferredPodcastFormats')
|
||||
if podcast_formats_str:
|
||||
podcast_formats = podcast_formats_str.split(',')
|
||||
preferred_podcast_formats = []
|
||||
for pod_format in podcast_formats:
|
||||
pod_format = pod_format.lower().strip()
|
||||
if '/' not in pod_format:
|
||||
pod_format = 'audio/' + pod_format
|
||||
if pod_format in preferred_podcast_formats:
|
||||
continue
|
||||
preferred_podcast_formats.append(pod_format)
|
||||
|
||||
if args.rss:
|
||||
session = create_session(None)
|
||||
testRSS = get_rss(base_dir, domain, session, args.rss,
|
||||
False, False, 1000, 1000, 1000, 1000, debug)
|
||||
False, False, 1000, 1000, 1000, 1000, debug,
|
||||
preferred_podcast_formats)
|
||||
pprint(testRSS)
|
||||
sys.exit()
|
||||
|
||||
|
@ -3429,7 +3453,8 @@ if args.defaultCurrency:
|
|||
|
||||
if __name__ == "__main__":
|
||||
print('allowdeletion: ' + str(args.allowdeletion))
|
||||
run_daemon(args.check_actor_timeout,
|
||||
run_daemon(preferred_podcast_formats,
|
||||
args.check_actor_timeout,
|
||||
crawlers_allowed,
|
||||
args.dyslexic_font,
|
||||
content_license_url,
|
||||
|
|
|
@ -817,7 +817,8 @@ def run_newswire_daemon(base_dir: str, httpd,
|
|||
httpd.max_newswire_posts,
|
||||
httpd.maxCategoriesFeedItemSizeKb,
|
||||
httpd.system_language,
|
||||
httpd.debug)
|
||||
httpd.debug,
|
||||
httpd.preferred_podcast_formats)
|
||||
|
||||
if not httpd.newswire:
|
||||
print('Newswire feeds not updated')
|
||||
|
|
115
newswire.py
115
newswire.py
|
@ -623,11 +623,61 @@ def xml_podcast_to_dict(base_dir: str, xml_item: str, xml_str: str) -> {}:
|
|||
return podcast_properties
|
||||
|
||||
|
||||
def get_link_from_rss_item(rss_item: str) -> (str, str):
|
||||
def get_link_from_rss_item(rss_item: str,
|
||||
preferred_mime_types: [],
|
||||
proxy_type: str) -> (str, str):
|
||||
"""Extracts rss link from rss item string
|
||||
"""
|
||||
mime_type = None
|
||||
|
||||
if preferred_mime_types and '<podcast:alternateEnclosure ' in rss_item:
|
||||
enclosures = rss_item.split('<podcast:alternateEnclosure ')
|
||||
ctr = 0
|
||||
for enclosure in enclosures:
|
||||
if ctr == 0:
|
||||
ctr += 1
|
||||
continue
|
||||
ctr += 1
|
||||
if '</podcast:alternateEnclosure' not in enclosure:
|
||||
continue
|
||||
enclosure = enclosure.split('</podcast:alternateEnclosure')[0]
|
||||
if 'type="' not in enclosure:
|
||||
continue
|
||||
mime_type = enclosure.split('type="')[1]
|
||||
if '"' in mime_type:
|
||||
mime_type = mime_type.split('"')[0]
|
||||
if mime_type not in preferred_mime_types:
|
||||
continue
|
||||
if 'uri="' not in enclosure:
|
||||
continue
|
||||
uris = enclosure.split('uri="')
|
||||
ctr2 = 0
|
||||
for uri in uris:
|
||||
if ctr2 == 0:
|
||||
ctr2 += 1
|
||||
continue
|
||||
ctr2 += 1
|
||||
if '"' not in uri:
|
||||
continue
|
||||
link = uri.split('"')[0]
|
||||
if '://' not in link:
|
||||
continue
|
||||
if proxy_type:
|
||||
if proxy_type == 'tor' and \
|
||||
'.onion/' not in link:
|
||||
continue
|
||||
if proxy_type == 'onion' and \
|
||||
'.onion/' not in link:
|
||||
continue
|
||||
if proxy_type == 'i2p' and \
|
||||
'.i2p/' not in link:
|
||||
continue
|
||||
return link, mime_type
|
||||
else:
|
||||
if '.onion/' not in link and \
|
||||
'.i2p/' not in link:
|
||||
return link, mime_type
|
||||
|
||||
if '<enclosure ' in rss_item:
|
||||
# get link from audio or video enclosure
|
||||
enclosure = rss_item.split('<enclosure ')[1]
|
||||
|
@ -667,7 +717,8 @@ def _xml2str_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
max_posts_per_source: int,
|
||||
max_feed_item_size_kb: int,
|
||||
max_categories_feedItem_size_kb: int,
|
||||
session, debug: bool) -> {}:
|
||||
session, debug: bool,
|
||||
preferred_podcast_formats: []) -> {}:
|
||||
"""Converts an xml RSS 2.0 string to a dictionary
|
||||
"""
|
||||
if '<item>' not in xml_str:
|
||||
|
@ -719,7 +770,15 @@ def _xml2str_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
description = description.split('</media:description>')[0]
|
||||
description = remove_html(description)
|
||||
|
||||
link, link_mime_type = get_link_from_rss_item(rss_item)
|
||||
proxy_type = None
|
||||
if domain.endswith('.onion'):
|
||||
proxy_type = 'tor'
|
||||
elif domain.endswith('.i2p'):
|
||||
proxy_type = 'i2p'
|
||||
|
||||
link, link_mime_type = \
|
||||
get_link_from_rss_item(rss_item, preferred_podcast_formats,
|
||||
proxy_type)
|
||||
if not link:
|
||||
continue
|
||||
|
||||
|
@ -762,7 +821,8 @@ def _xml1str_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
max_posts_per_source: int,
|
||||
max_feed_item_size_kb: int,
|
||||
max_categories_feedItem_size_kb: int,
|
||||
session, debug: bool) -> {}:
|
||||
session, debug: bool,
|
||||
preferred_podcast_formats: []) -> {}:
|
||||
"""Converts an xml RSS 1.0 string to a dictionary
|
||||
https://validator.w3.org/feed/docs/rss1.html
|
||||
"""
|
||||
|
@ -816,7 +876,15 @@ def _xml1str_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
description = description.split('</media:description>')[0]
|
||||
description = remove_html(description)
|
||||
|
||||
link, link_mime_type = get_link_from_rss_item(rss_item)
|
||||
proxy_type = None
|
||||
if domain.endswith('.onion'):
|
||||
proxy_type = 'tor'
|
||||
elif domain.endswith('.i2p'):
|
||||
proxy_type = 'i2p'
|
||||
|
||||
link, link_mime_type = \
|
||||
get_link_from_rss_item(rss_item, preferred_podcast_formats,
|
||||
proxy_type)
|
||||
if not link:
|
||||
continue
|
||||
|
||||
|
@ -858,7 +926,8 @@ def _atom_feed_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
moderated: bool, mirrored: bool,
|
||||
max_posts_per_source: int,
|
||||
max_feed_item_size_kb: int,
|
||||
session, debug: bool) -> {}:
|
||||
session, debug: bool,
|
||||
preferred_podcast_formats: []) -> {}:
|
||||
"""Converts an atom feed string to a dictionary
|
||||
"""
|
||||
if '<entry>' not in xml_str:
|
||||
|
@ -901,7 +970,15 @@ def _atom_feed_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
description = description.split('</media:description>')[0]
|
||||
description = remove_html(description)
|
||||
|
||||
link, link_mime_type = get_link_from_rss_item(atom_item)
|
||||
proxy_type = None
|
||||
if domain.endswith('.onion'):
|
||||
proxy_type = 'tor'
|
||||
elif domain.endswith('.i2p'):
|
||||
proxy_type = 'i2p'
|
||||
|
||||
link, link_mime_type = \
|
||||
get_link_from_rss_item(atom_item, preferred_podcast_formats,
|
||||
proxy_type)
|
||||
if not link:
|
||||
continue
|
||||
|
||||
|
@ -1105,7 +1182,7 @@ def _atom_feed_yt_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
description = description.split('</summary>')[0]
|
||||
description = remove_html(description)
|
||||
|
||||
link, _ = get_link_from_rss_item(atom_item)
|
||||
link, _ = get_link_from_rss_item(atom_item, None, None)
|
||||
if not link:
|
||||
link = atom_item.split('<yt:videoId>')[1]
|
||||
link = link.split('</yt:videoId>')[0]
|
||||
|
@ -1146,7 +1223,8 @@ def _xml_str_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
max_posts_per_source: int,
|
||||
max_feed_item_size_kb: int,
|
||||
max_categories_feedItem_size_kb: int,
|
||||
session, debug: bool) -> {}:
|
||||
session, debug: bool,
|
||||
preferred_podcast_formats: []) -> {}:
|
||||
"""Converts an xml string to a dictionary
|
||||
"""
|
||||
if '<yt:videoId>' in xml_str and '<yt:channelId>' in xml_str:
|
||||
|
@ -1161,18 +1239,19 @@ def _xml_str_to_dict(base_dir: str, domain: str, xml_str: str,
|
|||
xml_str, moderated, mirrored,
|
||||
max_posts_per_source, max_feed_item_size_kb,
|
||||
max_categories_feedItem_size_kb,
|
||||
session, debug)
|
||||
session, debug,
|
||||
preferred_podcast_formats)
|
||||
if '<?xml version="1.0"' in xml_str:
|
||||
return _xml1str_to_dict(base_dir, domain,
|
||||
xml_str, moderated, mirrored,
|
||||
max_posts_per_source, max_feed_item_size_kb,
|
||||
max_categories_feedItem_size_kb,
|
||||
session, debug)
|
||||
session, debug, preferred_podcast_formats)
|
||||
if 'xmlns="http://www.w3.org/2005/Atom"' in xml_str:
|
||||
return _atom_feed_to_dict(base_dir, domain,
|
||||
xml_str, moderated, mirrored,
|
||||
max_posts_per_source, max_feed_item_size_kb,
|
||||
session, debug)
|
||||
session, debug, preferred_podcast_formats)
|
||||
if 'https://jsonfeed.org/version/1' in xml_str:
|
||||
return _json_feed_v1to_dict(base_dir, domain,
|
||||
xml_str, moderated, mirrored,
|
||||
|
@ -1198,7 +1277,8 @@ def get_rss(base_dir: str, domain: str, session, url: str,
|
|||
moderated: bool, mirrored: bool,
|
||||
max_posts_per_source: int, max_feed_size_kb: int,
|
||||
max_feed_item_size_kb: int,
|
||||
max_categories_feedItem_size_kb: int, debug: bool) -> {}:
|
||||
max_categories_feedItem_size_kb: int, debug: bool,
|
||||
preferred_podcast_formats: []) -> {}:
|
||||
"""Returns an RSS url as a dict
|
||||
"""
|
||||
if not isinstance(url, str):
|
||||
|
@ -1231,7 +1311,8 @@ def get_rss(base_dir: str, domain: str, session, url: str,
|
|||
max_posts_per_source,
|
||||
max_feed_item_size_kb,
|
||||
max_categories_feedItem_size_kb,
|
||||
session, debug)
|
||||
session, debug,
|
||||
preferred_podcast_formats)
|
||||
else:
|
||||
print('WARN: feed is too large, ' +
|
||||
'or contains invalid characters: ' + url)
|
||||
|
@ -1476,7 +1557,8 @@ def get_dict_from_newswire(session, base_dir: str, domain: str,
|
|||
max_tags: int, max_feed_item_size_kb: int,
|
||||
max_newswire_posts: int,
|
||||
max_categories_feedItem_size_kb: int,
|
||||
system_language: str, debug: bool) -> {}:
|
||||
system_language: str, debug: bool,
|
||||
preferred_podcast_formats: []) -> {}:
|
||||
"""Gets rss feeds as a dictionary from newswire file
|
||||
"""
|
||||
subscriptions_filename = base_dir + '/accounts/newswire.txt'
|
||||
|
@ -1517,7 +1599,8 @@ def get_dict_from_newswire(session, base_dir: str, domain: str,
|
|||
moderated, mirrored,
|
||||
max_posts_per_source, max_feed_size_kb,
|
||||
max_feed_item_size_kb,
|
||||
max_categories_feedItem_size_kb, debug)
|
||||
max_categories_feedItem_size_kb, debug,
|
||||
preferred_podcast_formats)
|
||||
if items_list:
|
||||
for date_str, item in items_list.items():
|
||||
result[date_str] = item
|
||||
|
|
2
posts.py
2
posts.py
|
@ -1445,7 +1445,7 @@ def _create_post_base(base_dir: str,
|
|||
if nickname != 'news':
|
||||
content = \
|
||||
replace_emoji_from_tags(None, base_dir, content, tags, 'content',
|
||||
False)
|
||||
False, True)
|
||||
# remove replaced emoji
|
||||
hashtags_dict_copy = hashtags_dict.copy()
|
||||
for tag_name, tag in hashtags_dict_copy.items():
|
||||
|
|
|
@ -104,13 +104,17 @@ def _speaker_pronounce(base_dir: str, say_text: str, translate: {}) -> str:
|
|||
"Tor": "Toor",
|
||||
"memes": "meemes",
|
||||
"Memes": "Meemes",
|
||||
"rofl": "roll on the floor laughing",
|
||||
"ROFL": "roll on the floor laughing",
|
||||
"rofl": translate["laughing"],
|
||||
"ROFL": translate["laughing"],
|
||||
"lmao": translate["laughing"],
|
||||
"LMAO": translate["laughing"],
|
||||
"fwiw": "for what it's worth",
|
||||
"fyi": "for your information",
|
||||
"irl": "in real life",
|
||||
"IRL": "in real life",
|
||||
"imho": "in my opinion",
|
||||
"afaik": "as far as I know",
|
||||
"AFAIK": "as far as I know",
|
||||
"fediverse": "fediiverse",
|
||||
"Fediverse": "Fediiverse",
|
||||
" foss ": " free and open source software ",
|
||||
|
@ -124,6 +128,7 @@ def _speaker_pronounce(base_dir: str, say_text: str, translate: {}) -> str:
|
|||
"#nowplaying": translate["hashtag"] + " now-playing",
|
||||
"#NowPlaying": translate["hashtag"] + " now-playing",
|
||||
"#": translate["hashtag"] + ' ',
|
||||
"¯\\_(ツ)_/¯": translate["shrug"],
|
||||
":D": '. ' + translate["laughing"],
|
||||
":-D": '. ' + translate["laughing"],
|
||||
":)": '. ' + translate["smile"],
|
||||
|
|
97
tests.py
97
tests.py
|
@ -827,8 +827,10 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
dyslexic_font = False
|
||||
crawlers_allowed = []
|
||||
check_actor_timeout = 2
|
||||
preferred_podcast_formats = None
|
||||
print('Server running: Alice')
|
||||
run_daemon(check_actor_timeout,
|
||||
run_daemon(preferred_podcast_formats,
|
||||
check_actor_timeout,
|
||||
crawlers_allowed,
|
||||
dyslexic_font,
|
||||
content_license_url,
|
||||
|
@ -984,8 +986,10 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
dyslexic_font = False
|
||||
crawlers_allowed = []
|
||||
check_actor_timeout = 2
|
||||
preferred_podcast_formats = None
|
||||
print('Server running: Bob')
|
||||
run_daemon(check_actor_timeout,
|
||||
run_daemon(preferred_podcast_formats,
|
||||
check_actor_timeout,
|
||||
crawlers_allowed,
|
||||
dyslexic_font,
|
||||
content_license_url,
|
||||
|
@ -1064,8 +1068,10 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
|||
dyslexic_font = False
|
||||
crawlers_allowed = []
|
||||
check_actor_timeout = 2
|
||||
preferred_podcast_formats = None
|
||||
print('Server running: Eve')
|
||||
run_daemon(check_actor_timeout,
|
||||
run_daemon(preferred_podcast_formats,
|
||||
check_actor_timeout,
|
||||
crawlers_allowed,
|
||||
dyslexic_font,
|
||||
content_license_url,
|
||||
|
@ -1146,8 +1152,10 @@ def create_server_group(path: str, domain: str, port: int,
|
|||
dyslexic_font = False
|
||||
crawlers_allowed = []
|
||||
check_actor_timeout = 2
|
||||
preferred_podcast_formats = None
|
||||
print('Server running: Group')
|
||||
run_daemon(check_actor_timeout,
|
||||
run_daemon(preferred_podcast_formats,
|
||||
check_actor_timeout,
|
||||
crawlers_allowed,
|
||||
dyslexic_font,
|
||||
content_license_url,
|
||||
|
@ -3673,9 +3681,23 @@ def _test_addemoji(base_dir: str):
|
|||
tags.append(tag)
|
||||
content = content_modified
|
||||
content_modified = \
|
||||
replace_emoji_from_tags(None, base_dir, content, tags, 'content', True)
|
||||
# print('content_modified: ' + content_modified)
|
||||
assert content_modified == '<p>Emoji 🍋 🍓 🍌</p>'
|
||||
replace_emoji_from_tags(None, base_dir, content, tags, 'content',
|
||||
True, True)
|
||||
expected_content = '<p>Emoji 🍋 🍓 🍌</p>'
|
||||
if content_modified != expected_content:
|
||||
print('expected_content: ' + expected_content)
|
||||
print('content_modified: ' + content_modified)
|
||||
assert content_modified == expected_content
|
||||
content_modified = \
|
||||
replace_emoji_from_tags(None, base_dir, content, tags, 'content',
|
||||
True, False)
|
||||
expected_content = '<p>Emoji <span aria-hidden="true">🍋</span>' + \
|
||||
' <span aria-hidden="true">🍓</span> ' + \
|
||||
'<span aria-hidden="true">🍌</span></p>'
|
||||
if content_modified != expected_content:
|
||||
print('expected_content: ' + expected_content)
|
||||
print('content_modified: ' + content_modified)
|
||||
assert content_modified == expected_content
|
||||
|
||||
os.chdir(base_dir_original)
|
||||
shutil.rmtree(base_dir_original + '/.tests',
|
||||
|
@ -6775,31 +6797,74 @@ def _test_xml_podcast_dict(base_dir: str) -> None:
|
|||
assert len(podcast_properties['locations']) == 1
|
||||
|
||||
|
||||
def _test_get_link_from_rss_item() -> None:
|
||||
def _test_link_from_rss_item() -> None:
|
||||
print('test_get_link_from_rssitem')
|
||||
rss_item = \
|
||||
'<link>' + \
|
||||
'https://anchor.fm/creativecommons/episodes/' + \
|
||||
'Hessel-van-Oorschot-of-Tribe-of-Noise--Free-Music-Archive-e1crvce' + \
|
||||
'</link>' + \
|
||||
'<pubDate>Wed, 12 Jan 2022 14:28:46 GMT</pubDate>' + \
|
||||
'</link>\n' + \
|
||||
'<pubDate>Wed, 12 Jan 2022 14:28:46 GMT</pubDate>\n' + \
|
||||
'<enclosure url="https://anchor.fm/s/4d70d828/podcast/' + \
|
||||
'play/46054222/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net' + \
|
||||
'%2Fstaging%2F2022-0-12%2F7352f28c-a928-ea7a-65ae-' + \
|
||||
'ccb5edffbac1.mp3" length="67247880" type="audio/mpeg"/>'
|
||||
link, mime_type = get_link_from_rss_item(rss_item)
|
||||
'ccb5edffbac1.mp3" length="67247880" type="audio/mpeg"/>\n' + \
|
||||
'<podcast:alternateEnclosure type="audio/mpeg" ' + \
|
||||
'length="27800000" bitrate="128000" default="true" ' + \
|
||||
'title="Standard">\n' + \
|
||||
'<podcast:source uri="https://whoframed.rodger/rabbit.mp3" />\n' + \
|
||||
'<podcast:source uri="http://randomaddress.onion/rabbit.mp3" />\n' + \
|
||||
'<podcast:source uri="http://randomaddress.i2p/rabbit.mp3" />\n' + \
|
||||
'</podcast:alternateEnclosure>\n' + \
|
||||
'<podcast:alternateEnclosure type="audio/opus" ' + \
|
||||
'length="19200000" bitrate="128000" ' + \
|
||||
'title="High Quality">\n' + \
|
||||
'<podcast:source uri="https://whoframed.rodger/rabbit.opus" />\n' + \
|
||||
'<podcast:source uri="http://randomaddress.onion/rabbit.opus" />\n' + \
|
||||
'<podcast:source uri="http://randomaddress.i2p/rabbit.opus" />\n' + \
|
||||
'</podcast:alternateEnclosure>\n'
|
||||
|
||||
link, mime_type = get_link_from_rss_item(rss_item, None, None)
|
||||
assert link
|
||||
assert link.endswith('.mp3')
|
||||
assert link.endswith('1.mp3')
|
||||
assert mime_type
|
||||
assert mime_type == 'audio/mpeg'
|
||||
|
||||
link, mime_type = get_link_from_rss_item(rss_item, ['audio/mp3'], None)
|
||||
assert link
|
||||
assert link.endswith('1.mp3')
|
||||
assert mime_type
|
||||
assert mime_type == 'audio/mpeg'
|
||||
|
||||
link, mime_type = get_link_from_rss_item(rss_item, ['audio/mpeg'], None)
|
||||
assert link
|
||||
assert link == 'https://whoframed.rodger/rabbit.mp3'
|
||||
assert mime_type
|
||||
assert mime_type == 'audio/mpeg'
|
||||
|
||||
link, mime_type = get_link_from_rss_item(rss_item, ['audio/opus'], None)
|
||||
assert mime_type
|
||||
if mime_type != 'audio/opus':
|
||||
print('mime_type: ' + mime_type)
|
||||
assert mime_type == 'audio/opus'
|
||||
assert link
|
||||
assert link == 'https://whoframed.rodger/rabbit.opus'
|
||||
|
||||
link, mime_type = get_link_from_rss_item(rss_item, ['audio/opus'], 'tor')
|
||||
assert mime_type
|
||||
if mime_type != 'audio/opus':
|
||||
print('mime_type: ' + mime_type)
|
||||
assert mime_type == 'audio/opus'
|
||||
assert link
|
||||
assert link == 'http://randomaddress.onion/rabbit.opus'
|
||||
|
||||
rss_item = \
|
||||
'<link>' + \
|
||||
'https://anchor.fm/creativecommons/episodes/' + \
|
||||
'Hessel-van-Oorschot-of-Tribe-of-Noise--Free-Music-Archive-e1crvce' + \
|
||||
'</link>' + \
|
||||
'<pubDate>Wed, 12 Jan 2022 14:28:46 GMT</pubDate>'
|
||||
link, mime_type = get_link_from_rss_item(rss_item)
|
||||
link, mime_type = get_link_from_rss_item(rss_item, None, None)
|
||||
assert link
|
||||
assert link.startswith('https://anchor.fm')
|
||||
assert not mime_type
|
||||
|
@ -6810,7 +6875,7 @@ def _test_get_link_from_rss_item() -> None:
|
|||
'Hessel-van-Oorschot-of-Tribe-of-Noise--Free-Music-Archive-e1crvce' + \
|
||||
'"/>' + \
|
||||
'<pubDate>Wed, 12 Jan 2022 14:28:46 GMT</pubDate>'
|
||||
link, mime_type = get_link_from_rss_item(rss_item)
|
||||
link, mime_type = get_link_from_rss_item(rss_item, None, None)
|
||||
assert link
|
||||
assert link.startswith('https://test.link/creativecommons')
|
||||
|
||||
|
@ -7026,7 +7091,7 @@ def run_all_tests():
|
|||
_test_bold_reading()
|
||||
_test_published_to_local_timezone()
|
||||
_test_safe_webtext()
|
||||
_test_get_link_from_rss_item()
|
||||
_test_link_from_rss_item()
|
||||
_test_xml_podcast_dict(base_dir)
|
||||
_test_get_actor_from_in_reply_to()
|
||||
_test_valid_emoji_content()
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "السواحيلية",
|
||||
"lang_zh": "صينى",
|
||||
"Common emoji": "الرموز التعبيرية الشائعة",
|
||||
"Copy and paste into your text": "نسخ ولصق في النص الخاص بك"
|
||||
"Copy and paste into your text": "نسخ ولصق في النص الخاص بك",
|
||||
"shrug": "هز كتفيه"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Suahili",
|
||||
"lang_zh": "Xinès",
|
||||
"Common emoji": "Emoji comú",
|
||||
"Copy and paste into your text": "Copia i enganxa al teu text"
|
||||
"Copy and paste into your text": "Copia i enganxa al teu text",
|
||||
"shrug": "arronsar les espatlles"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Tseiniaidd",
|
||||
"Common emoji": "Emoji cyffredin",
|
||||
"Copy and paste into your text": "Copïwch a gludwch i'ch testun"
|
||||
"Copy and paste into your text": "Copïwch a gludwch i'ch testun",
|
||||
"shrug": "shrug"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Suaheli",
|
||||
"lang_zh": "Chinesisch",
|
||||
"Common emoji": "Gewöhnliches Emoji",
|
||||
"Copy and paste into your text": "Kopieren und in Ihren Text einfügen"
|
||||
"Copy and paste into your text": "Kopieren und in Ihren Text einfügen",
|
||||
"shrug": "zucken"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Chinese",
|
||||
"Common emoji": "Common emoji",
|
||||
"Copy and paste into your text": "Copy and paste into your text"
|
||||
"Copy and paste into your text": "Copy and paste into your text",
|
||||
"shrug": "shrug"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "China",
|
||||
"Common emoji": "Emoticonos comunes",
|
||||
"Copy and paste into your text": "Copia y pega en tu texto"
|
||||
"Copy and paste into your text": "Copia y pega en tu texto",
|
||||
"shrug": "encogimiento de hombros"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Chinoise",
|
||||
"Common emoji": "Émoji commun",
|
||||
"Copy and paste into your text": "Copiez et collez dans votre texte"
|
||||
"Copy and paste into your text": "Copiez et collez dans votre texte",
|
||||
"shrug": "hausser les épaules"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Síneach",
|
||||
"Common emoji": "Emoji coitianta",
|
||||
"Copy and paste into your text": "Cóipeáil agus greamaigh isteach i do théacs"
|
||||
"Copy and paste into your text": "Cóipeáil agus greamaigh isteach i do théacs",
|
||||
"shrug": "shrug"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "चीनी",
|
||||
"Common emoji": "आम इमोजी",
|
||||
"Copy and paste into your text": "अपने टेक्स्ट में कॉपी और पेस्ट करें"
|
||||
"Copy and paste into your text": "अपने टेक्स्ट में कॉपी और पेस्ट करें",
|
||||
"shrug": "कंधे उचकाने की क्रिया"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Cinese",
|
||||
"Common emoji": "Emoji comuni",
|
||||
"Copy and paste into your text": "Copia e incolla nel tuo testo"
|
||||
"Copy and paste into your text": "Copia e incolla nel tuo testo",
|
||||
"shrug": "scrollare le spalle"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "スワヒリ語",
|
||||
"lang_zh": "中国語",
|
||||
"Common emoji": "一般的な絵文字",
|
||||
"Copy and paste into your text": "コピーしてテキストに貼り付けます"
|
||||
"Copy and paste into your text": "コピーしてテキストに貼り付けます",
|
||||
"shrug": "肩をすくめる"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "스와힐리어",
|
||||
"lang_zh": "중국인",
|
||||
"Common emoji": "일반적인 이모티콘",
|
||||
"Copy and paste into your text": "텍스트에 복사하여 붙여넣기"
|
||||
"Copy and paste into your text": "텍스트에 복사하여 붙여넣기",
|
||||
"shrug": "어깨를 으쓱하다"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Swahîlîyî",
|
||||
"lang_zh": "Çînî",
|
||||
"Common emoji": "Emojiyên hevpar",
|
||||
"Copy and paste into your text": "Di nivîsa xwe de kopî bikin û bixin"
|
||||
"Copy and paste into your text": "Di nivîsa xwe de kopî bikin û bixin",
|
||||
"shrug": "şuştin"
|
||||
}
|
||||
|
|
|
@ -542,5 +542,6 @@
|
|||
"lang_sw": "Swahili",
|
||||
"lang_zh": "Chinese",
|
||||
"Common emoji": "Common emoji",
|
||||
"Copy and paste into your text": "Copy and paste into your text"
|
||||
"Copy and paste into your text": "Copy and paste into your text",
|
||||
"shrug": "shrug"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Suahili",
|
||||
"lang_zh": "Chiński",
|
||||
"Common emoji": "Popularne emotikony",
|
||||
"Copy and paste into your text": "Skopiuj i wklej do swojego tekstu"
|
||||
"Copy and paste into your text": "Skopiuj i wklej do swojego tekstu",
|
||||
"shrug": "wzruszać ramionami"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Suaíli",
|
||||
"lang_zh": "Chinês",
|
||||
"Common emoji": "Emoji comum",
|
||||
"Copy and paste into your text": "Copie e cole no seu texto"
|
||||
"Copy and paste into your text": "Copie e cole no seu texto",
|
||||
"shrug": "dar de ombros"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "суахили",
|
||||
"lang_zh": "Китайский",
|
||||
"Common emoji": "Общие смайлики",
|
||||
"Copy and paste into your text": "Скопируйте и вставьте в свой текст"
|
||||
"Copy and paste into your text": "Скопируйте и вставьте в свой текст",
|
||||
"shrug": "пожимание плечами"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "Kiswahili",
|
||||
"lang_zh": "Kichina",
|
||||
"Common emoji": "Emoji ya kawaida",
|
||||
"Copy and paste into your text": "Nakili na ubandike kwenye maandishi yako"
|
||||
"Copy and paste into your text": "Nakili na ubandike kwenye maandishi yako",
|
||||
"shrug": "piga mabega"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "суахілі",
|
||||
"lang_zh": "китайський",
|
||||
"Common emoji": "Звичайні емодзі",
|
||||
"Copy and paste into your text": "Скопіюйте та вставте у свій текст"
|
||||
"Copy and paste into your text": "Скопіюйте та вставте у свій текст",
|
||||
"shrug": "знизати плечима"
|
||||
}
|
||||
|
|
|
@ -546,5 +546,6 @@
|
|||
"lang_sw": "斯瓦希里语",
|
||||
"lang_zh": "中国人",
|
||||
"Common emoji": "常见表情符号",
|
||||
"Copy and paste into your text": "复制并粘贴到您的文本中"
|
||||
"Copy and paste into your text": "复制并粘贴到您的文本中",
|
||||
"shrug": "耸耸肩"
|
||||
}
|
||||
|
|
|
@ -2109,7 +2109,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
|||
content_str = \
|
||||
replace_emoji_from_tags(session, base_dir, content_str,
|
||||
post_json_object['object']['tag'],
|
||||
'content', False)
|
||||
'content', False, True)
|
||||
|
||||
if is_muted:
|
||||
content_str = ''
|
||||
|
|
|
@ -984,12 +984,12 @@ def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
|
|||
display_name = \
|
||||
replace_emoji_from_tags(session, base_dir,
|
||||
display_name, emoji_tags_list,
|
||||
'post header', False)
|
||||
'post header', False, False)
|
||||
else:
|
||||
display_name = \
|
||||
replace_emoji_from_tags(session, base_dir,
|
||||
display_name, emoji_tags_list, 'profile',
|
||||
False)
|
||||
False, False)
|
||||
# print('TAG: display_name after tags 2: ' + display_name)
|
||||
|
||||
# remove any stray emoji
|
||||
|
|
Loading…
Reference in New Issue