Adding many more Stack Exchange Zim subscriptions.

This commit is contained in:
Roland 2024-02-12 12:40:56 -07:00
parent 407d60c074
commit 971eb4f99a
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 87 additions and 1 deletions

View file

@ -134,6 +134,46 @@ KIWIX_CATALOG = [
'languages': ['en'],
'size': 62 * 1048576,
},
{
'name': 'DIY (Stack Exchange)',
'languages': ['en'],
'size': 930 * 1048576,
},
{
'name': 'Electronics (Stack Exchange)',
'languages': ['en'],
'size': 1.4 * 1073741824,
},
{
'name': 'Unix (Stack Exchange)',
'languages': ['en'],
'size': 1.1 * 1073741824,
},
{
'name': 'Ask Ubuntu (Stack Exchange)',
'languages': ['en'],
'size': 1.9 * 1073741824,
},
{
'name': 'Bicycles (Stack Exchange)',
'languages': ['en'],
'size': 350 * 1048576,
},
{
'name': 'Biology (Stack Exchange)',
'languages': ['en'],
'size': 350 * 1048576,
},
{
'name': 'Arduino (Stack Exchange)',
'languages': ['en'],
'size': 240 * 1048576,
},
{
'name': '3D Printing (Stack Exchange)',
'languages': ['en'],
'size': 100 * 1048576,
},
]
KIWIX_CATALOG_BY_NAME = {i['name']: i for i in KIWIX_CATALOG}

View file

@ -323,6 +323,20 @@ async def subscribe(name: str, language: str, session: Session = None,
url = f'https://download.kiwix.org/zim/gutenberg/gutenberg_{language}_all_'
elif name == 'Amateur Radio (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/ham.stackexchange.com_{language}_all_'
elif name == 'DIY (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/diy.stackexchange.com_{language}_all_'
elif name == 'Electronics (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/electronics.stackexchange.com_{language}_all'
elif name == 'Unix (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/unix.stackexchange.com_{language}_all'
elif name == 'Ask Ubuntu (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/askubuntu.com_{language}_all_'
elif name == 'Bicycles (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/bicycles.stackexchange.com_{language}_all_'
elif name == 'Biology (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/biology.stackexchange.com_{language}_all_'
elif name == '3D Printing (Stack Exchange)':
url = f'https://download.kiwix.org/zim/stack_exchange/3dprinting.stackexchange.com_{language}_all_'
else:
raise ValueError(f'{name} not a valid Kiwix subscription name!')
@ -387,6 +401,22 @@ def zim_download_url_to_name(url: str) -> Tuple[str, str]:
name = 'Gutenberg'
elif project == 'ham.stackexchange.com' and flavor == '_all_':
name = 'Amateur Radio (Stack Exchange)'
elif project == 'diy.stackexchange.com' and flavor == '_all_':
name = 'DIY (Stack Exchange)'
elif project == 'electronics.stackexchange.com' and flavor == '_all_':
name = 'Electronics (Stack Exchange)'
elif project == 'unix.stackexchange.com' and flavor == '_all_':
name = 'Unix (Stack Exchange)'
elif project == 'askubuntu.com' and flavor == '_all_':
name = 'Ask Ubuntu (Stack Exchange)'
elif project == 'bicycles.stackexchange.com' and flavor == '_all_':
name = 'Bicycles (Stack Exchange)'
elif project == 'biology.stackexchange.com' and flavor == '_all_':
name = 'Biology (Stack Exchange)'
elif project == 'arduino.stackexchange.com' and flavor == '_all_':
name = 'Arduino (Stack Exchange)'
elif project == '3dprinting.stackexchange.com' and flavor == '_all_':
name = '3D Printing (Stack Exchange)'
else:
raise RuntimeError(f'Could not find name for Zim URL: {url} {project=} {flavor=}')

View file

@ -264,7 +264,23 @@ def test_zim_tag_migration(test_session, test_directory, zim_factory, tag_factor
('https://download.kiwix.org/zim/ifixit/ifixit_nl_all_', ('iFixit', 'nl')),
('https://download.kiwix.org/zim/gutenberg/gutenberg_ang_all_', ('Gutenberg', 'ang')),
('https://download.kiwix.org/zim/stack_exchange/ham.stackexchange.com_en_all_',
('Amateur Radio (Stack Exchange)', 'en'))
('Amateur Radio (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/diy.stackexchange.com_en_all_',
('DIY (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/electronics.stackexchange.com_en_all_',
('Electronics (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/unix.stackexchange.com_en_all_',
('Unix (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/askubuntu.com_en_all_',
('Ask Ubuntu (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/bicycles.stackexchange.com_en_all_',
('Bicycles (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/biology.stackexchange.com_en_all_',
('Biology (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/arduino.stackexchange.com_en_all_',
('Arduino (Stack Exchange)', 'en')),
('https://download.kiwix.org/zim/stack_exchange/3dprinting.stackexchange.com_en_all_',
('3D Printing (Stack Exchange)', 'en')),
]
)
def test_zim_download_url_to_name(url, expected):