<commit_before>local youtube_dl = {}

function youtube_dl:init(config)
  youtube_dl.triggers = {
	"^/(mp4) https?://w?w?w?%.?youtu.be/([A-Za-z0-9-_-]+)",
	"^/(mp4) https?://w?w?w?m?%.?youtube.com/embed/([A-Za-z0-9-_-]+)",
	"^/(mp4) https?://w?w?w?m?%.?youtube.com/watch%?v=([A-Za-z0-9-_-]+)",
	"^/(mp3) https?://w?w?w?m?%.?youtu.be/([A-Za-z0-9-_-]+)",
	"^/(mp3) https?://w?w?w?m?%.?youtube.com/embed/([A-Za-z0-9-_-]+)",
	"^/(mp3) https?://w?w?w?m?%.?youtube.com/watch%?v=([A-Za-z0-9-_-]+)"
  }
	
  youtube_dl.doc = [[*
]]..config.cmd_pat..[[mp3* _<URL>_: Lädt Audio von YouTube
*]]..config.cmd_pat..[[mp4* _<URL>_: Lädt Video von YouTube
]]
end

youtube_dl.command = 'mp3 <URL>, /mp4 <URL>'

function youtube_dl:get_availabe_formats(id, hash)
  local ytdl_json = io.popen('youtube-dl -j https://www.youtube.com/watch/?v='..id):read('*all')
  if not ytdl_json then return end
  local data = json.decode(ytdl_json)
  
  local available_formats = {}
  redis:hset(hash, 'duration', data.duration)
  
  -- Building table with infos
  for n=1, #data.formats do
    local vid_format = data.formats[n].format
	local format_num = vid_format:match('^(%d+) ')	 
	local valid_nums = {['17'] = true, ['36'] = true, ['43'] = true, ['18'] = true, ['22'] = true}<commit_msg>YouTube_DL: Fehler, wenn Video entfernt wurde/nicht existiert<commit_after>local youtube_dl = {}

function youtube_dl:init(config)
  youtube_dl.triggers = {
	"^/(mp4) https?://w?w?w?%.?youtu.be/([A-Za-z0-9-_-]+)",
	"^/(mp4) https?://w?w?w?m?%.?youtube.com/embed/([A-Za-z0-9-_-]+)",
	"^/(mp4) https?://w?w?w?m?%.?youtube.com/watch%?v=([A-Za-z0-9-_-]+)",
	"^/(mp3) https?://w?w?w?m?%.?youtu.be/([A-Za-z0-9-_-]+)",
	"^/(mp3) https?://w?w?w?m?%.?youtube.com/embed/([A-Za-z0-9-_-]+)",
	"^/(mp3) https?://w?w?w?m?%.?youtube.com/watch%?v=([A-Za-z0-9-_-]+)"
  }
	
  youtube_dl.doc = [[*
]]..config.cmd_pat..[[mp3* _<URL>_: Lädt Audio von YouTube
*]]..config.cmd_pat..[[mp4* _<URL>_: Lädt Video von YouTube
]]
end

youtube_dl.command = 'mp3 <URL>, /mp4 <URL>'

function youtube_dl:get_availabe_formats(id, hash)
  local ytdl_json = io.popen('youtube-dl -j https://www.youtube.com/watch/?v='..id):read('*all')
  if not ytdl_json then return end
  local data = json.decode(ytdl_json)
  if not data then return nil end
  
  local available_formats = {}
  redis:hset(hash, 'duration', data.duration)
  
  -- Building table with infos
  for n=1, #data.formats do
    local vid_format = data.formats[n].format
	local format_num = vid_format:match('^(%d+) ')	 
	local valid_nums = {['17'] = true, ['36'] = true, ['43'] = true, ['18'] = true, ['22'] = true}
{'fraction_non_alphanumeric': 0.2636643571978445, 'fraction_numerical': 0.025404157043879907, 'mean_word_length': 4.007707129094412, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2619977', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1182, 'n_words': 180}