diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po
index c6eaa0696..30b9f3177 100644
--- a/resources/language/resource.language.en_gb/strings.po
+++ b/resources/language/resource.language.en_gb/strings.po
@@ -1588,3 +1588,19 @@ msgstr ""
msgctxt "#30820"
msgid "Podcast"
msgstr ""
+
+msgctxt "#30821"
+msgid "Auto-like watched videos"
+msgstr ""
+
+msgctxt "#30822"
+msgid "Channel filtering"
+msgstr ""
+
+msgctxt "#30823"
+msgid "Disable filtering to auto-like all videos. Enable filtering to auto-like videos only from specific channels. Enable blacklist to auto-like all videos except from specific channels."
+msgstr ""
+
+msgctxt "#30824"
+msgid "Filter by channel names separated by a comma eg. 'The Best Channel,The 2nd Best Channel'"
+msgstr ""
diff --git a/resources/lib/youtube_plugin/kodion/constants/const_settings.py b/resources/lib/youtube_plugin/kodion/constants/const_settings.py
index d2e8b5c2d..a5a40a4b0 100644
--- a/resources/lib/youtube_plugin/kodion/constants/const_settings.py
+++ b/resources/lib/youtube_plugin/kodion/constants/const_settings.py
@@ -113,8 +113,16 @@
RATE_VIDEOS = 'youtube.post.play.rate' # (bool)
RATE_PLAYLISTS = 'youtube.post.play.rate.playlists' # (bool)
-PLAY_REFRESH = 'youtube.post.play.refresh' # (bool)
+AUTO_LIKE = 'youtube.post.play.auto_like' # (bool)
+AUTO_LIKE_FILTER_LIST = 'youtube.post.play.auto_like.filter.list' # (str)
+AUTO_LIKE_FILTER_STATE = 'youtube.post.play.auto_like.filter.state' # (int)
+
+FILTER_DISABLED = 0
+FILTER_ENABLED = 1
+FILTER_BLACKLIST = 2
+
+PLAY_REFRESH = 'youtube.post.play.refresh' # (bool)
WATCH_LATER_REMOVE = 'youtube.playlist.watchlater.autoremove' # (bool)
VERIFY_SSL = 'requests.ssl.verify' # (bool)
diff --git a/resources/lib/youtube_plugin/kodion/monitors/player_monitor.py b/resources/lib/youtube_plugin/kodion/monitors/player_monitor.py
index 53b6bcc07..be114430e 100644
--- a/resources/lib/youtube_plugin/kodion/monitors/player_monitor.py
+++ b/resources/lib/youtube_plugin/kodion/monitors/player_monitor.py
@@ -27,6 +27,7 @@
VIDEO_ID,
)
from ..utils.redact import redact_params
+from ..utils.convert_format import channel_filter_split
class PlayerMonitorThread(threading.Thread):
@@ -298,22 +299,45 @@ def run(self):
if history_id and history_id.lower() != 'hl':
client.add_video_to_playlist(history_id, video_id)
- # rate video
- if (settings.get_bool(settings.RATE_VIDEOS) and
- (settings.get_bool(settings.RATE_PLAYLISTS)
- or xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() < 2)):
+ new_rating = False
+
+ # Auto like video
+ if settings.auto_like_enabled():
+ filter_state = settings.auto_like_filter_state()
+ if filter_state == settings.FILTER_DISABLED:
+ new_rating = 'like'
+ else:
+ _, filters_set, _ = channel_filter_split(
+ settings.auto_like_filter()
+ )
+ if filters_set and self.channel_id and client.channel_match(
+ identifier=self.channel_id,
+ identifiers=filters_set,
+ exclude=filter_state == settings.FILTER_BLACKLIST,
+ ):
+ new_rating = 'like'
+
+ # Otherwise manually rate video
+ if (not new_rating
+ and settings.get_bool(settings.RATE_VIDEOS)
+ and (settings.get_bool(settings.RATE_PLAYLISTS)
+ or xbmc.PlayList(xbmc.PLAYLIST_VIDEO).size() < 2)):
json_data = client.get_video_rating(video_id)
if json_data:
items = json_data.get('items', [{'rating': 'none'}])
rating = items[0].get('rating', 'none')
if rating == 'none':
- provider.on_video_x(
- provider,
- context,
- command='rate',
- video_id=video_id,
- current_rating=rating,
- )
+ new_rating = None
+
+ if new_rating is not False:
+ provider.on_video_x(
+ provider,
+ context,
+ command='rate',
+ video_id=video_id,
+ current_rating='none',
+ new_rating=new_rating,
+ )
if settings.get_bool(settings.PLAY_REFRESH):
context.send_notification(REFRESH_CONTAINER)
diff --git a/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py b/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
index 8add3b9e3..75929776b 100644
--- a/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
+++ b/resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
@@ -720,6 +720,30 @@ def subscriptions_filter(self, value=None):
', ', ','
)
+ def auto_like_enabled(self, value=None):
+ if value is not None:
+ return self.set_bool(
+ SETTINGS.AUTO_LIKE, value
+ )
+ return self.get_bool(SETTINGS.AUTO_LIKE, False)
+
+ def auto_like_filter_state(self, value=None):
+ default = SETTINGS.FILTER_DISABLED
+ if value is not None:
+ return self.set_int(
+ SETTINGS.AUTO_LIKE_FILTER_STATE, value
+ )
+ return self.get_int(SETTINGS.AUTO_LIKE_FILTER_STATE, default)
+
+ def auto_like_filter(self, value=None):
+ if value is not None:
+ if isinstance(value, (list, tuple, set)):
+ value = ','.join(value).lstrip(',')
+ return self.set_string(SETTINGS.AUTO_LIKE_FILTER_LIST, value)
+ return self.get_string(SETTINGS.AUTO_LIKE_FILTER_LIST).replace(
+ ', ', ','
+ )
+
def shorts_duration(self, value=None):
if value is not None:
return self.set_int(SETTINGS.SHORTS_DURATION, value)
diff --git a/resources/settings.xml b/resources/settings.xml
index 310f15abb..4fd73b6cd 100644
--- a/resources/settings.xml
+++ b/resources/settings.xml
@@ -999,6 +999,52 @@
true
+
+ 0
+ false
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+
+
+
+ 0
+
+
+ true
+
+
+
+ 0
+
+
+
+ true
+ 0
+
+
+
+
+ 587
+
+
0
false