Vorbereitung Release 0.2.0 #83
@@ -94,12 +94,14 @@ if __name__ == '__main__':
|
||||
response = requests.get("http://127.0.0.1:8800/api/media/actors")
|
||||
data = response.json()
|
||||
actors = {}
|
||||
actors_id = {}
|
||||
for item in data:
|
||||
actor = {}
|
||||
actor['id'] = item['id']
|
||||
actor['name'] = item['name']
|
||||
actor['url'] = item['url']
|
||||
actors[item['url']] = actor
|
||||
actors_id[item['id']] = actor
|
||||
log.debug(f'all actors: {actors}')
|
||||
files_url = ""
|
||||
if args.all:
|
||||
@@ -109,7 +111,10 @@ if __name__ == '__main__':
|
||||
response = requests.get(files_url)
|
||||
log.debug(f"Status: {response.status_code}")
|
||||
data = response.json()
|
||||
entries_count = len(data)
|
||||
entries_index = 1
|
||||
log.debug(f"data: {len(data)}")
|
||||
missing_actors = []
|
||||
for item in data:
|
||||
link = item['url']
|
||||
if not link:
|
||||
@@ -123,17 +128,28 @@ if __name__ == '__main__':
|
||||
if actor_link in actors:
|
||||
log.debug(f"found actor with id: {actors[actor_link]['id']}")
|
||||
actor_list.append(actors[actor_link])
|
||||
else:
|
||||
log.info(f"found actor {actor_link} missing")
|
||||
if actor_link not in missing_actors:
|
||||
missing_actors.append(actor_link)
|
||||
actor_response = requests.put(f"http://127.0.0.1:8800/api/media/files/{item['id']}/actors", json=actor_list)
|
||||
actor_data = actor_response.json()
|
||||
persisted_actor_links: int = len(actor_data)
|
||||
found_actor_links: int = len(actor_links)
|
||||
if persisted_actor_links != found_actor_links:
|
||||
if persisted_actor_links < found_actor_links:
|
||||
log.warning(f"{persisted_actor_links} links persisted, but {found_actor_links} links are available")
|
||||
log.info(f"found actors: {actor_links}")
|
||||
item['review'] = True
|
||||
elif persisted_actor_links > found_actor_links:
|
||||
log.warning("more persisted links than found actors")
|
||||
item['review'] = True
|
||||
else:
|
||||
item['review'] = False
|
||||
log.debug(f"found {persisted_actor_links} actors")
|
||||
log.debug(f"found actors: {actor_data}")
|
||||
item['review'] = False
|
||||
update = requests.put(f"http://127.0.0.1:8800/api/media/files/{item['id']}", json=item)
|
||||
log.debug(f"update status: {update.status_code}")
|
||||
log.debug(f"update result: {update.json()}")
|
||||
log.warning(f"processed {entries_index}/{entries_count}")
|
||||
entries_index += 1
|
||||
log.info(f"missing actors: {missing_actors}")
|
||||
log.warning('kontor.find_links finished')
|
||||
|
||||
Reference in New Issue
Block a user