def get_subs_by_season(showid, lang, season): url = SUBS_BY_SEASON.format(sid=showid, s=season, lang=lang) data = get_content(url) filenames = get_datas(data.getElementsByTagName('filename')) links = get_datas(data.getElementsByTagName('downloadlink')) eps = defaultdict(lambda: []) for f, l in zip(filenames, links): _, _, e = nameparser.get_ep_details(f) eps[e].append((f, l)) return eps