Merge lp:~phill-ridout/openlp/ftw-json into lp:openlp/ftw-data

Proposed by Phill
Status: Merged
Approved by: Raoul Snyman
Approved revision: 21
Merged at revision: 20
Proposed branch: lp:~phill-ridout/openlp/ftw-json
Merge into: lp:openlp/ftw-data
Diff against target: 434 lines (+412/-1)
3 files modified
download_3.0.json (+326/-0)
scripts/hashgen.py (+1/-1)
scripts/jsongen.py (+85/-0)
To merge this branch: bzr merge lp:~phill-ridout/openlp/ftw-json
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tomas Groth Approve
Review via email: mp+363049@code.launchpad.net

This proposal supersedes a proposal from 2019-02-11.

Commit message

Add a JSON formatted config file for easier parsing and associated script

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Two things:

1. Please add a commit message or a description ^^

2. Your new JSON file is either "download_3.0.json" or "download_3.0.conf" depending on whether you look at the file name, or the constant on line 366 of the diff below. Please choose one.

review: Needs Fixing
Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal

2 minor things.

review: Needs Fixing
Revision history for this message
Tomas Groth (tomasgroth) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'download_3.0.json'
--- download_3.0.json 1970-01-01 00:00:00 +0000
+++ download_3.0.json 2019-02-12 10:51:53 +0000
@@ -0,0 +1,326 @@
1{
2 "_comments": "The most recent version should be added to http://openlp.org/files/frw/download_3.0.json",
3 "_meta": {
4 "base_url": "https://get.openlp.org/ftw/",
5 "bibles_dir": "bibles",
6 "songs_dir": "songs",
7 "themes_dir": "themes"
8 },
9 "bibles": {
10 "af": {
11 "title": "Afrikaans",
12 "translations": {
13 "afr": {
14 "file_name": "Afrikaans_Bybel.sqlite",
15 "sha256": "d4f12ebbb35bf589e791200dd2f320cf89f894b53953724edb458570f47affcf",
16 "title": "Afrikaanse Bybel"
17 }
18 }
19 },
20 "ar": {
21 "title": "العربية (Arabic)",
22 "translations": {
23 "kelh": {
24 "file_name": "Ketab-EL-Hayat.sqlite",
25 "sha256": "7b5d4c46fbd77477db0503b4565f1d558f6e29cf7e7e74f2ae48fbbe14766dde",
26 "title": "Ketab EL Hayat"
27 },
28 "sp": {
29 "file_name": "Syriac_Peshitta_NT.sqlite",
30 "sha256": "a7a1ccb205e8e0c92707344e90efbf0c8e60c8ad95eeb216c8b41ce23a231eef",
31 "title": "Syriac Peshitta"
32 },
33 "vd": {
34 "file_name": "VanDyke-Without-Vowels.sqlite",
35 "sha256": "b3d216b92c62954da7b69c27eb2872b1163f49fa290a23acc6cb3274d1f68f56",
36 "title": "VanDyke Without Vowels"
37 },
38 "vdv": {
39 "file_name": "VanDyke-With-Vowels.sqlite",
40 "sha256": "c1767d8bc2e6aff9097f63f3f9a15af134841ee3fdf40267adba3263f5a6ba0f",
41 "title": "VanDyke With Vowels"
42 }
43 }
44 },
45 "cz": {
46 "title": "Čeština (Czech)",
47 "translations": {
48 "csp": {
49 "file_name": "Cesky_studijni_preklad.sqlite",
50 "sha256": "93885991c10d4ce71418c33b77cba7a321f7c66fe0d40edd7bd474160517d666",
51 "title": "Český Studijní Překlad"
52 },
53 "krl": {
54 "file_name": "Kralicka_Bible_1613.sqlite",
55 "sha256": "9d9e25e3361eeb9d550aea571aad55c4320b592ed28a4fa1cf4b0dad5ee382f4",
56 "title": "Kralická Bible 1613"
57 },
58 "prk": {
59 "file_name": "Bible_Preklad_21_stoleti.sqlite",
60 "sha256": "1fad90dc62bad7d246092dc4792eb39b89f910cf4fac0efd2bd35c69fcd89acf",
61 "title": "Bible, Překlad 21. století"
62 }
63 }
64 },
65 "de": {
66 "title": "Deutsch",
67 "translations": {
68 "145": {
69 "file_name": "Luther_1545.sqlite",
70 "sha256": "965ca4df59fc6af80472be00fb9a92e1539792b42f2f7c368d9623d057293098",
71 "title": "Luther 1545"
72 },
73 "elb": {
74 "file_name": "Elberfelder_1905.sqlite",
75 "sha256": "32cf96da94be0df237584130df7b840b82828c753db0664393d354a4c7ac246b",
76 "title": "Elberfelder"
77 },
78 "l12": {
79 "file_name": "Luther_1912.sqlite",
80 "sha256": "2606b991f3254699cd236c6420b59789238118338e2778f7ed4c494861eb05ad",
81 "title": "Luther 1912"
82 },
83 "mb": {
84 "file_name": "Menge_Bibel.sqlite",
85 "sha256": "cad8ce0974e1b1823c8830738258941c95af2cf3a79dd3eb9e27659eb02fbdf6",
86 "title": "Menge"
87 }
88 }
89 },
90 "en": {
91 "title": "English",
92 "translations": {
93 "asv": {
94 "file_name": "ASV.sqlite",
95 "sha256": "064637d15c1dd9940682460b8040f6fe1d025dd8f40637ca13c5fbdb14012d09",
96 "title": "American Standard Version"
97 },
98 "kjv": {
99 "file_name": "KJV.sqlite",
100 "sha256": "09e2d9d68777c75acc8b587b6be1f5253f86274774529e57a2902c14d9802d3d",
101 "title": "King James Version"
102 }
103 }
104 },
105 "eo": {
106 "title": "Esperanto",
107 "translations": {
108 "esb": {
109 "file_name": "Esperanto_Bible.sqlite",
110 "sha256": "58c716f18382be192a077cb85934720315847e6b168340784df896d365ca495b",
111 "title": "Esperanto Biblio"
112 }
113 }
114 },
115 "es": {
116 "title": "Español",
117 "translations": {
118 "lse": {
119 "file_name": "Las_Sagradas_Escrituras.sqlite",
120 "sha256": "c6654ef283f1139ba2b8d36238f38ad88a31b71599c79be3fad88db4350de939",
121 "title": "Las Sagradas Escrituras"
122 }
123 }
124 },
125 "fi": {
126 "title": "Suomi",
127 "translations": {
128 "fi3338": {
129 "file_name": "FI_33_38_OpenLP.sqlite",
130 "sha256": "3a3dd8b5ec16a7cf5547f13b9ce4490e83ddc032b87b9a0efb383da6ab35fd70",
131 "title": "33/38 - Vanha kirkkoraamattu"
132 },
133 "fi92": {
134 "file_name": "FI_92_OpenLP.sqlite",
135 "sha256": "c0f0b0de574c65db60daa88b5f54d514901ae7bc86cf9933478d76575016a050",
136 "title": "92 - Uusi kirkkoraamattu"
137 },
138 "firk": {
139 "file_name": "FI_Raamattu_Kansalle_OpenLP.sqlite",
140 "sha256": "6982cb2b5b1061611211e62e8910289ff8702f934ddf785b7978524d3f8f9544",
141 "title": "Raamattu Kansalle -käännös"
142 }
143 }
144 },
145 "fr": {
146 "title": "Français",
147 "translations": {
148 "lsb": {
149 "file_name": "Louis_Segon_Bible.sqlite",
150 "sha256": "8e548c384f92ee54ea46930a1547fcc574f039c3f8eaa918707f5692ceafc069",
151 "title": "Louis Segon"
152 }
153 }
154 },
155 "hu": {
156 "title": "Magyar",
157 "translations": {
158 "ma": {
159 "file_name": "Magyar_jford_t_s.sqlite",
160 "sha256": "5509b117616e64da2486b71c344a4b58ec87634d29b0ddda528185fae19779d2",
161 "title": "Magyar Újfordítású"
162 }
163 }
164 },
165 "nl": {
166 "title": "Nederlandse",
167 "translations": {
168 "sta": {
169 "file_name": "Statenvertaling.sqlite",
170 "sha256": "b2a699caff81c81ae11b705b09bfc85da832953ae28d838bef536e8a6c406822",
171 "title": "Statenvertaling"
172 }
173 }
174 },
175 "no": {
176 "title": "Nederlandse",
177 "translations": {
178 "no1921": {
179 "file_name": "Norsk-SMB-1921.sqlite",
180 "sha256": "a7afc5b77cd54eb11c9b7d20813d56e164e935cf69ee0b38ae4126ce809a5fcd",
181 "title": "Studentmållagsbibelen (1921)"
182 },
183 "no1930": {
184 "file_name": "Norsk-NB-1930.sqlite",
185 "sha256": "641a3b52ed7fb8b2027703a1f7241577929ac97f91cf18c6e0ad9c235032b9f8",
186 "title": "Norsk bokmål (1930)"
187 }
188 }
189 },
190 "pt": {
191 "title": "Português",
192 "translations": {
193 "jo": {
194 "file_name": "Jo_o_Ferreira_de_Almeida_Atualizada.sqlite",
195 "sha256": "ada5f15802a5c80cdf27ef188858d4c64e2a5d92b158c4bec7c5ca54e7cddcb1",
196 "title": "João Ferreira de Almeida Atualizada"
197 }
198 }
199 },
200 "ru": {
201 "title": "Русский",
202 "translations": {
203 "rst": {
204 "file_name": "RST.sqlite",
205 "sha256": "86cf69addcbd93ea53842916bc7b90c77154415880b04c933679ea9dac1cf976",
206 "title": "Синодальный перевод"
207 }
208 }
209 },
210 "sv": {
211 "title": "Slovak",
212 "translations": {
213 "ssv": {
214 "file_name": "Sv_t_P_smo_Katol_cky_Preklad.sqlite",
215 "sha256": "2d9ed24fe3eece4a20ecfb0228a92729d5d681bb8b65cb7f6dde18ca2839f5d8",
216 "title": "Sväté Písmo (Katolícky Preklad)"
217 }
218 }
219 },
220 "th": {
221 "title": "ภาษาไทย",
222 "translations": {
223 "tkjv": {
224 "file_name": "TKJV.sqlite",
225 "sha256": "b053589c2d8f760556e5df2018d77b2bfda6c658e79835046d5e173ab2d341d9",
226 "title": "พระคัมภีร์ภาษาไทยฉบับ KJV"
227 }
228 }
229 },
230 "tl": {
231 "title": "Tagalog",
232 "translations": {
233 "ang": {
234 "file_name": "Ang_Dating_Biblia.sqlite",
235 "sha256": "226b74a02323f56bb146e10e522e186d2387bbe2e3082b74297f1c97ce420673",
236 "title": "Ang Dating"
237 }
238 }
239 },
240 "uma": {
241 "title": "Uma (Indonesia)",
242 "translations": {
243 "uma": {
244 "file_name": "Uma_Version.sqlite",
245 "sha256": "59ea6b77e246790794172cae0ecf70a34e59b602f0791d19789763faad12e368",
246 "title": "Uma Version"
247 }
248 }
249 }
250 },
251 "songs": {
252 "ar": {
253 "file_name": "songs_ar.sqlite",
254 "sha256": "2113f239e2c470d4d464f08e21008a7f77fd001bc01ebea3f6857852c2708712",
255 "title": "Arabic"
256 },
257 "de": {
258 "file_name": "songs_de.sqlite",
259 "sha256": "bff85ee11f7f7d667cd2867a639f59f15958d5df6ac0eeedf4da7cc4facd8165",
260 "title": "Deutsch"
261 },
262 "en": {
263 "file_name": "songs_en.sqlite",
264 "sha256": "8a5e862f0ce651a9ae8cc93c938b0bb5059f2380ac445096a346480e928bb045",
265 "title": "English"
266 },
267 "fi": {
268 "file_name": "songs_fi.sqlite",
269 "sha256": "601ac772d9a9a685059456186437aae128d5da30573ff08595c7f8752613a851",
270 "title": "Suomi"
271 },
272 "hu": {
273 "file_name": "songs_hu.sqlite",
274 "sha256": "1cd693f2c829eb6274dfce606cc52478cfdc6a05f00e07bdd20d0f72a18167e4",
275 "title": "Magyar"
276 },
277 "ru": {
278 "file_name": "songs_ru.sqlite",
279 "sha256": "1416c3e6b551c90c4e4cb797df368a617b7a5cfec814f0fad8882ab21024aee0",
280 "title": "Русский"
281 },
282 "th": {
283 "file_name": "songs_th.sqlite",
284 "sha256": "1066596a3941d2bcb1fad83ae81ccce146ea10ce73be57615e55f7cb02e2ceb7",
285 "title": "ภาษาไทย"
286 }
287 },
288 "themes": {
289 "bb": {
290 "file_name": "BlueBurst.otz",
291 "sha256": "6105626b6da8b358adb8eedb9da986f1149667a1bff324f8bd4549345d2fad56",
292 "thumbnail": "BlueBurst.png",
293 "title": "Blue Burst"
294 },
295 "cl": {
296 "file_name": "Clouds.otz",
297 "sha256": "d28eafd838be33df58e7ff160d29b0c3ec7024927b62fa2308aa5b259f31d5ea",
298 "thumbnail": "Clouds.png",
299 "title": "Clouds"
300 },
301 "geop": {
302 "file_name": "Geo_Purple.otz",
303 "sha256": "aee81f16183122d14c0ca9f7582d3adbe1eb8c932c635885fcfb2c50fc36c1aa",
304 "thumbnail": "Geo_Purple.png",
305 "title": "Geo Purple"
306 },
307 "mot": {
308 "file_name": "Moss_on_tree.otz",
309 "sha256": "b3b9d286610f7639fedf21a04670f011801f79c06004d7d4295c947a0c584462",
310 "thumbnail": "Moss_on_tree.png",
311 "title": "Moss on tree"
312 },
313 "swt": {
314 "file_name": "Sea_with_trees.otz",
315 "sha256": "66a9c831fa8c6805ba22502f2544469a717bf74c1f2a206a1b45e09b95493eed",
316 "thumbnail": "Sea_with_trees.png",
317 "title": "Sea with trees"
318 },
319 "wt": {
320 "file_name": "Wheat.otz",
321 "sha256": "63fde97b7d35722c8fe06e1cfe8236e6d212d944d43c04f6b77f5156b83f5a3f",
322 "thumbnail": "Wheat.png",
323 "title": "Wheat"
324 }
325 }
326}
0\ No newline at end of file327\ No newline at end of file
1328
=== modified file 'scripts/hashgen.py'
--- scripts/hashgen.py 2017-03-07 18:42:08 +0000
+++ scripts/hashgen.py 2019-02-12 10:51:53 +0000
@@ -5,7 +5,7 @@
5###############################################################################5###############################################################################
6# OpenLP - Open Source Lyrics Projection #6# OpenLP - Open Source Lyrics Projection #
7# --------------------------------------------------------------------------- #7# --------------------------------------------------------------------------- #
8# Copyright (c) 2008-2015 OpenLP Developers #8# Copyright (c) 2008-2019 OpenLP Developers #
9# --------------------------------------------------------------------------- #9# --------------------------------------------------------------------------- #
10# This program is free software; you can redistribute it and/or modify it #10# This program is free software; you can redistribute it and/or modify it #
11# under the terms of the GNU General Public License as published by the Free #11# under the terms of the GNU General Public License as published by the Free #
1212
=== added file 'scripts/jsongen.py'
--- scripts/jsongen.py 1970-01-01 00:00:00 +0000
+++ scripts/jsongen.py 2019-02-12 10:51:53 +0000
@@ -0,0 +1,85 @@
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
4
5###############################################################################
6# OpenLP - Open Source Lyrics Projection #
7# --------------------------------------------------------------------------- #
8# Copyright (c) 2008-2019 OpenLP Developers #
9# --------------------------------------------------------------------------- #
10# This program is free software; you can redistribute it and/or modify it #
11# under the terms of the GNU General Public License as published by the Free #
12# Software Foundation; version 2 of the License. #
13# #
14# This program is distributed in the hope that it will be useful, but WITHOUT #
15# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
16# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
17# more details. #
18# #
19# You should have received a copy of the GNU General Public License along #
20# with this program; if not, write to the Free Software Foundation, Inc., 59 #
21# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
22###############################################################################
23"""
24This script (re)generates a SHA256 hash for each file in the download_3.0.json file
25"""
26import json
27from hashlib import sha256
28from pathlib import Path
29
30CONFIG_FILE_NAME = 'download_3.0.json'
31
32def hash_file(file_path, block_size=65536):
33 """
34 Hash the given file block by block for memory efficiency
35
36 :param pathlib.Path file_path: Path to file to hash.
37 :param int block_size: Size of blocks to process the file in.
38 :return: The sha256 hash of the file.
39 :rtype: str
40 """
41 with file_path.open(mode='rb') as file:
42 print(f'Calculating hash for {file_path}')
43 hasher = sha256()
44 buf = file.read(block_size)
45 while len(buf) > 0:
46 hasher.update(buf)
47 buf = file.read(block_size)
48 return hasher.hexdigest()
49
50
51def main():
52 """
53 Parse the json resource file and calculate a hash for each file
54 """
55 cfg_file_path = Path('..', CONFIG_FILE_NAME)
56 if not cfg_file_path.exists():
57 print(f'Can\'t find {cfg_file_path}. You need to run hashgen.py from the scripts directory.')
58 return False
59
60 with cfg_file_path.open(mode='r', encoding='utf-8') as config_file:
61 config = json.load(config_file)
62
63 meta = config['_meta']
64 song_folder = Path('..', meta['songs_dir'])
65 for lang in config['songs'].values():
66 song_db_path = song_folder / lang['file_name']
67 lang['sha256'] = hash_file(song_db_path)
68
69 bible_folder = Path('..', meta['bibles_dir'])
70 for lang in config['bibles'].values():
71 for translation in lang['translations'].values():
72 bible_db_path = bible_folder / translation['file_name']
73 translation['sha256'] = hash_file(bible_db_path)
74
75 theme_folder = Path('..', meta['themes_dir'])
76 for theme in config['themes'].values():
77 theme_db_path = theme_folder / theme['file_name']
78 theme['sha256'] = hash_file(theme_db_path)
79
80 with cfg_file_path.open(mode='w', encoding='utf-8') as config_file:
81 json.dump(config, config_file, sort_keys=True, indent=2, ensure_ascii=False)
82
83
84if __name__ == '__main__':
85 main()

Subscribers

People subscribed via source and target branches

to all changes: