Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions automated_quality_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def get_ten_random_assets(team_id: str) -> List[str]:
response.raise_for_status()

assets = response.json()
asset_count = len(assets)
if not assets:
raise ValueError(f"No eligible assets found for team {team_id}")

return [assets[random.randint(0, asset_count - 1)]["id"] for _ in range(10)]
return [random.choice(assets)["id"] for _ in range(10)]


def get_screens() -> List[Dict[str, Any]]:
Expand Down Expand Up @@ -115,10 +116,12 @@ def delete_playlist(playlist_id):
Delete a playlist and its items. In v4, label associations and playlist
items must be removed before the playlist itself can be deleted.
"""
requests.delete(
labels_response = requests.delete(
f"https://api.screenlyapp.com/v4/labels/playlists?playlist_id=eq.{playlist_id}",
headers=REQUEST_HEADERS,
)
if not labels_response.ok:
return False
items_response = requests.delete(
f"https://api.screenlyapp.com/v4/playlist-items?playlist_id=eq.{playlist_id}",
headers=REQUEST_HEADERS,
Expand Down
Loading