import bunny, json

medias = json.load(open('videos.json', 'r'))
videoIDS = [media['url'].split('/')[-1] for media in medias]

videos = bunny.list_videos()

with open('allVideos.json', 'w') as f:
    json.dump(videos, f, indent=4)

missingVideos = []
for video in videos:
    if video['guid'] in videoIDS:
        continue
    missingVideos.append(video)

datas = []
for video in missingVideos:
    data = {
        'guid': video['guid'],
        'title': video['title'],
        'length': video['length'],
        'width': video['width'],
        'height': video['height'],
        'availableResolutions': video['availableResolutions'],
        'storageSize': video['storageSize'],
        'hasMP4Fallback': video['hasMP4Fallback'],
        'category': video['category'],
    }
    datas.append(data)

with open('missing_videos.json', 'w') as f:
    json.dump(datas, f, indent=4)
