#!/usr/bin/env python
from __future__ import unicode_literals
import json, re, sys;
sys.path.append('.')
from yt_dlp.extractor import gen_extractor_classes
regexdict = {}
for cls in gen_extractor_classes():
    if cls.working() and hasattr(cls, '_VALID_URL'):
        name = cls.__name__
        regex = re.sub(r'(?<!\\)((\\{2})*)# .*$(?m)', "\\1", cls._VALID_URL)
        regex = re.sub(r'(?<!\\)((\\{2})*)\s+', "\\1", regex)
        regexdict[name] = re.compile(regex).pattern
filename = "youtube-dl_regex.json"
f = open(filename, "w")
f.write(json.dumps(regexdict))
f.close()
print(f"Created Regex-File: {filename}")
