diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ffae79..232584b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### v2.0.5 - 20-06-2024: + * [#42](https://github.com/elmoiv/redvid/pull/35) Fixed maximum and minimum video qualities not fetched. +### v2.0.4 - 04-03-2024: + * [#39](https://github.com/elmoiv/redvid/issues/39) Fixed audio not downloaded due to new Reddit patches. ### v2.0.3 - 27-11-2023: * [#35](https://github.com/elmoiv/redvid/pull/35) Fixed random audio track given to videos with no audio track. * Temp cleaning is now true by default. Use `-nc` or `--noclean` to save temp files. diff --git a/redvid/__init__.py b/redvid/__init__.py index 77657b9..e1c18e6 100644 --- a/redvid/__init__.py +++ b/redvid/__init__.py @@ -5,4 +5,4 @@ __url__ = 'https://github.com/elmoiv/redvid' __description__ = 'Smart downloader for Reddit hosted videos' __license__ = 'GPL-v3.0' -__version__ = '2.0.4' \ No newline at end of file +__version__ = '2.0.5' \ No newline at end of file diff --git a/redvid/redvid.py b/redvid/redvid.py index 5f05dd4..2b15b62 100644 --- a/redvid/redvid.py +++ b/redvid/redvid.py @@ -103,8 +103,11 @@ def scrape(self): self.r_url + 'DASHPlaylist.mpd', _proxies=self.proxies ) + + max_min_qualities = getMaxMinQualities(self.page, self.r_url) + # v1.0.8: Fix new Reddit mechanism - VQS, AQS = mpdParse(mpd.text) + VQS, AQS = mpdParse(mpd.text, custom_video_qualities=max_min_qualities) if [VQS, AQS] == [0, 0]: raise BaseException('Qualities not found!') diff --git a/redvid/tools.py b/redvid/tools.py index 02d8377..d51fb9b 100644 --- a/redvid/tools.py +++ b/redvid/tools.py @@ -55,6 +55,11 @@ def getSizes(u, h, p, vs): ) return sizes +def getMaxMinQualities(page, vredd_url): + regex = rf'{vredd_url}(DASH_)(\d+)(\.mp4)' + Match = re.findall(regex, page.text) + return Match + # v1.1.1: if 'vcf.redd.it' in # we extract DASH quality names and store them in # the same form of original re.findall result @@ -69,7 +74,7 @@ def vcfRemover(BaseUrls, rgx): ) return list(convertToReTags) -def mpdParse(mpd): +def mpdParse(mpd, custom_video_qualities=[]): # v2.0.1: Fix for new reddit mechanism tags = r'(DASH_)(?!vtt)(.*?)(\.mp4)?' tags_a = r'(audio)(\.mp4)?' @@ -83,7 +88,12 @@ def mpdParse(mpd): audio_tags = [tag for tag in re_tags if 'audio' in j(tag).lower()] video_tags = list(set(re_tags) - set(audio_tags)) tag_aud = audio_tags[-1] if audio_tags else None - + + # v2.0.5: Adding max and min qualities + for quality in custom_video_qualities: + if quality not in video_tags: + video_tags.append(quality) + if not re_tags: return 0, 0