Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
10 changes: 9 additions & 1 deletion resources/lib/youtube_plugin/kodion/constants/const_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
46 changes: 35 additions & 11 deletions resources/lib/youtube_plugin/kodion/monitors/player_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
VIDEO_ID,
)
from ..utils.redact import redact_params
from ..utils.convert_format import channel_filter_split


class PlayerMonitorThread(threading.Thread):
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
46 changes: 46 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,52 @@
<default>true</default>
<control type="toggle"/>
</setting>
<setting id="youtube.post.play.auto_like" type="boolean" label="30821" help="">
<level>0</level>
<default>false</default>
<control type="toggle"/>
</setting>
<setting id="youtube.post.play.auto_like.filter.state" type="integer" parent="youtube.post.play.auto_like" label="30822" help="30823">
<level>0</level>
<default>0</default>
<constraints>
<options>
<option label="13106">0</option> <!-- Disabled -->
<option label="305">1</option> <!-- Enabled -->
<option label="30586">2</option> <!-- Blacklist -->
</options>
</constraints>
<dependencies>
<dependency type="enable">
<condition setting="youtube.post.play.auto_like" operator="is">true</condition>
</dependency>
<dependency type="visible">
<condition setting="youtube.post.play.auto_like" operator="is">true</condition>
</dependency>
</dependencies>
<control format="string" type="spinner"/>
</setting>
<setting id="youtube.post.play.auto_like.filter.list" type="string" parent="youtube.post.play.auto_like" label="587" help="30824">
<level>0</level>
<default/>
<constraints>
<allowempty>true</allowempty>
</constraints>
<dependencies>
<dependency type="enable">
<condition setting="youtube.post.play.auto_like.filter.state" operator="!is">0</condition>
</dependency>
<dependency type="visible">
<and>
<condition setting="youtube.post.play.auto_like" operator="is">true</condition>
<condition setting="youtube.post.play.auto_like.filter.state" operator="!is">0</condition>
</and>
</dependency>
</dependencies>
<control format="string" type="edit">
<heading>587</heading>
</control>
</setting>
<setting id="youtube.post.play.rate" type="boolean" label="30627" help="">
<level>0</level>
<default>false</default>
Expand Down