(type: 'anime' | 'manga')
| 87 | }; |
| 88 | |
| 89 | async function importList(type: 'anime' | 'manga'): Promise<void> { |
| 90 | if (blocked[type]) { |
| 91 | logger.log('Import already running'); |
| 92 | return; |
| 93 | } |
| 94 | blocked[type] = true; |
| 95 | logger.log(`Import ${type} database`); |
| 96 | try { |
| 97 | await api.settings.init(); |
| 98 | const listProvider = await getList(7, type); |
| 99 | const list = await listProvider.getCompleteList(); |
| 100 | await importEntries( |
| 101 | type, |
| 102 | list.map(el => ({ |
| 103 | uid: el.uid, |
| 104 | type: el.type, |
| 105 | title: el.title, |
| 106 | malId: el.malId, |
| 107 | cacheKey: el.cacheKey, |
| 108 | image: el.image, |
| 109 | score: el.score, |
| 110 | status: el.status, |
| 111 | watchedEp: el.watchedEp, |
| 112 | totalEp: el.totalEp, |
| 113 | url: el.url, |
| 114 | })), |
| 115 | ).then(() => { |
| 116 | blocked[type] = false; |
| 117 | setKey(`update_${type}`, Date.now()); |
| 118 | setKey(`update_mode_${type}`, api.settings.get('syncMode')); |
| 119 | }); |
| 120 | } catch (e) { |
| 121 | blocked[type] = false; |
| 122 | throw e; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | export interface Entry { |
| 127 | uid: number | string; |
no test coverage detected