def _add_item(pipeline_name): url = request.form.get("url") config = load_config() pipeline = config.pipeline[pipeline_name] for p in pipeline.pull: pull = pull_services[p.service] item_id = pull.parse_item_id(url) if item_id is None: continue ItemInfo.add_index(IndexItem(service=p.service, item_id=item_id), [pipeline_name]) ItemInfo.set_status(p.service, item_id, TaskStage.Fetching, TaskStatus.Queued) return redirect(f"/pipeline/{pipeline_name}") return "Unknown URL"
def update_subs(): config = load_config() for (stype, sfunc), service_type in subscribe_services.items(): if stype not in config.api: continue service_conf = list(config.api[stype].values())[0] service = service_type(service_conf) for name, channels in SubscribeSource.get_subs(stype, sfunc): for item in service.subscribe_index(name): if not ItemInfo.exists(item.service, item.item_id): ItemInfo.add_index(item, channels) print(stype.value, sfunc, name, item) ItemInfo.set_status(item.service, item.item_id, TaskStage.Fetching, TaskStatus.Queued) for item in service.subscribe_full(name): if not ItemInfo.exists(item.service, item.item_id): ItemInfo.add_item(item, channels) print(stype.value, sfunc, name, item) ItemInfo.set_status(item.service, item.item_id, TaskStage.Downloading, TaskStatus.Queued)