async def _fetch(self, device_id: str) -> List[Update]: """ Fetch an update and add it to the database if new :param device_id: device ID :return: Update object """ response: List[Dict] = await self._request(device_id) if response: updates = [] for item in response: filename = item['filename'] if update_in_db(filename): recovery_update = get_update_by_version(item['version']) update_stable_beta(recovery_update) continue update = self._get_update(item) if update: if update.branch == "Stable" and not get_update_by_version(update.version, method="Fastboot"): update.branch = "Stable Beta" add_to_db(update) self._logger.info(f"Added {filename} to db") updates.append(update) return updates
async def _fetch_fastboot(self, codename) -> Optional[Update]: """ Fetch an update and add it to the database if new :param codename: device codename :return: Update object """ url: str = await self._request_fastboot(codename) if url: filename = url.split('/')[-1] if update_in_db(filename): return update = self._get_fastboot_update(filename) if update: add_to_db(update) self._logger.info(f"Added {filename} to db") recovery_update = get_update_by_version(update.version) update_stable_beta(recovery_update) return update