Last active
January 18, 2024 21:56
-
-
Save pukkandan/077465b736b861ab1aa6bf8c9bdb322a to your computer and use it in GitHub Desktop.
yt-dlp plugin for https://returnyoutubedislike.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Moved to https://github.com/pukkandan/yt-dlp-returnyoutubedislike |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
SPDX-License-Identifier: MIT https://opensource.org/licenses/MIT | |
Copyright © 2022 [email protected] | |
yt-dlp plugin postprocessor for https://returnyoutubedislike.com/ | |
Needs yt-dlp v2022.04.08 or above | |
See https://github.com/yt-dlp/yt-dlp#plugins for how to install and | |
pass "--use-postprocessor ReturnYoutubeDislikes:when=pre_process" | |
to activate the PostProcessor | |
Fields defined in "RYD_FIELDS" are updated using the information from the API. | |
The original values of those fields and the response from the API are saved | |
under "RYD" key in the info dict | |
Note: The API has rate-limiting: https://returnyoutubedislike.com/docs/usage-rights | |
""" | |
from yt_dlp.postprocessor.common import PostProcessor | |
RYD_FIELDS = { | |
'like_count': 'likes', | |
'dislike_count': 'dislikes', | |
'average_rating': 'rating', | |
'view_count': 'viewCount', | |
} | |
SUPPORTED_EXTRACTORS = { | |
'Youtube', | |
} | |
class ReturnYoutubeDislikesPP(PostProcessor): | |
def run(self, info): | |
extractor = info['extractor_key'] | |
if extractor not in SUPPORTED_EXTRACTORS: | |
self.to_screen(f'{self.PP_NAME} is not supported for {extractor}') | |
return [], info | |
api_data = self._download_json( | |
f'https://returnyoutubedislikeapi.com/votes?videoId={info["id"]}') or {} | |
info['RYD'] = { | |
'response': api_data, | |
'original': {k: info.get(k) for k in RYD_FIELDS.keys()} | |
} | |
if api_data: | |
info.update({k: api_data.get(v) for k, v in RYD_FIELDS.items()}) | |
return [], info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment