Skip to content

Commit

Permalink
Merge pull request #4454 from mintsoft/matrix_ytchannel
Browse files Browse the repository at this point in the history
[plugin.video.ytchannels] 0.5.3
  • Loading branch information
basrieter authored Feb 11, 2024
2 parents 3dccce1 + 541b895 commit 2eeba9a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion plugin.video.ytchannels/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.ytchannels" name="YouTube Channels" version="0.5.2+matrix.1" provider-name="natko1412,mintsoft,yeahme49">
<addon id="plugin.video.ytchannels" name="YouTube Channels" version="0.5.3+matrix.1" provider-name="natko1412,mintsoft,yeahme49">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.six" version="1.11.0"/>
Expand Down
2 changes: 2 additions & 0 deletions plugin.video.ytchannels/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
===============================
Youtube Channels addon by yeahme49/mintsoft/natko1412
===============================
v0.5.3 [25-Jan-2024]
- Users can now change the minimum length a video needs to be to visible

v0.5.2 [11-Nov-2023]
-Removing noisy logging of shorts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,9 @@ msgid "Enable live streams"
msgstr ""

msgctxt "#30209"
msgid "Filter out shorts"
msgid "Filter out short videos"
msgstr ""

msgctxt "#30210"
msgid "Minimum duration to display (in seconds)"
msgstr ""
8 changes: 4 additions & 4 deletions plugin.video.ytchannels/resources/lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def get_channel_id(channel_username):
return 'not found'


def get_latest_from_channel(channel_id, page, filter_shorts):
def get_latest_from_channel(channel_id, page, filter_shorts, minimum_duration_in_seconds):
my_addon = xbmcaddon.Addon()
result_num = my_addon.getSetting('result_number')

Expand Down Expand Up @@ -440,7 +440,7 @@ def get_latest_from_channel(channel_id, page, filter_shorts):
duration = sorted_data[x]['contentDetails']['duration']
seconds = yt_time(duration)
date = re.search("[0-9]{4}-[0-9]{2}-[0-9]{2}", sorted_data[x]['snippet']['publishedAt'])
if filter_shorts and is_short(video_id, seconds):
if filter_shorts and is_too_short(video_id, seconds, minimum_duration_in_seconds):
continue

listout.append([title, video_id, thumb, desc, seconds, date.group()])
Expand All @@ -452,8 +452,8 @@ def redirect_request(self, req, fp, code, msg, hdrs, newurl):
return None # do not redirect, HTTPError will be raised


def is_short(videoId, seconds):
if seconds <= 60:
def is_too_short(videoId, seconds, minimum_duration_in_seconds):
if seconds <= minimum_duration_in_seconds:
return True
return False

Expand Down
21 changes: 11 additions & 10 deletions plugin.video.ytchannels/resources/lib/ytchannels.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def ytchannels_main():
enable_playlists = my_addon.getSetting('enable_playlists')
enable_livestreams = my_addon.getSetting('enable_livestreams')
filter_shorts = my_addon.getSetting('filter_shorts')
minimum_duration_in_seconds = my_addon.getSetting('minimum_duration_in_seconds')

addon_handle = int(sys.argv[1])
args = urllib.parse.parse_qs(sys.argv[2][1:])
Expand Down Expand Up @@ -244,18 +245,18 @@ def ytchannels_main():
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li,isFolder=True)

game_list=get_latest_from_channel(id, page, filter_shorts == 'true')
next_page=game_list[0]
video_list=get_latest_from_channel(id, page, filter_shorts == 'true', minimum_duration_in_seconds)
next_page=video_list[0]

xbmc_region = xbmc.getRegion('dateshort')

for i in range(1,len(game_list)):
title=game_list[i][0]
video_id=game_list[i][1]
thumb=game_list[i][2]
desc=game_list[i][3]
seconds=game_list[i][4]
date=game_list[i][5]
for i in range(1,len(video_list)):
title=video_list[i][0]
video_id=video_list[i][1]
thumb=video_list[i][2]
desc=video_list[i][3]
seconds=video_list[i][4]
date=video_list[i][5]

try:
pub = datetime.datetime.strftime(datetime.datetime.strptime(date, '%Y-%m-%d'), xbmc_region)
Expand All @@ -269,7 +270,7 @@ def ytchannels_main():
li.setProperty('IsPlayable', 'true')
li.setInfo('video', { 'genre': 'YouTube', 'plot': plot, 'duration': seconds } )

xbmcplugin.addDirectoryItem(handle=addon_handle, url=uri, listitem=li)#,isFolder=True)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=uri, listitem=li)

if next_page!='1':
if playlista:
Expand Down
13 changes: 13 additions & 0 deletions plugin.video.ytchannels/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
<default>false</default>
<control type="toggle"/>
</setting>
<setting id="minimum_duration_in_seconds" type="integer" label="30210">
<level>0</level>
<default>61</default>
<dependencies>
<dependency type="visible" setting="filter_shorts">true</dependency>
</dependencies>
<constraints>
<minimum>0</minimum>
</constraints>
<control type="edit" format="integer">
<heading>30210</heading>
</control>
</setting>
<setting id="result_number" type="integer" label="30203">
<level>0</level>
<default>20</default>
Expand Down

0 comments on commit 2eeba9a

Please sign in to comment.