Skip to content

Commit 48e4142

Browse files
feat(discord): add more sites
* drive * reddit * piped * nitter * libreddit
1 parent 0cdf1c3 commit 48e4142

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

discord.lua

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ local o = {
55
timeout = 2,
66
keybind = 'D',
77
enabled = false,
8+
invidious = 'yewtu%.be',
9+
piped = 'piped%.kavin%.rocks',
10+
nitter = 'nitter%.net',
11+
libreddit = 'libredd%.it',
812
client_id = '700723249889149038'
913
}
1014
require('mp.options').read_options(o, 'discord')
@@ -134,8 +138,8 @@ function RPC:recv(len)
134138
msg.error(data)
135139
return nil
136140
end
137-
assert(data:len() == len, 'incorrect data length')
138141
msg.debug('received', data:tohex())
142+
assert(data:len() == len, 'incorrect data length')
139143
return data
140144
end
141145

@@ -227,26 +231,38 @@ mp.register_event('file-loaded', function()
227231
time = time and 'Duration: '..os.date('!%T', time) or ''
228232
local plist = mp.get_property_number('playlist-count')
229233
if plist > 1 then
230-
local pos = mp.get_property('playlist-pos-1')
231-
plist = (' [%d/%d]'):format(pos, plist)
234+
local item = mp.get_property('playlist-pos')
235+
plist = (' [%d/%d]'):format(item + 1, plist)
236+
item = mp.get_property(('playlist/%d/title'):format(item))
237+
if item then title = item end
232238
else
233239
plist = ''
234240
end
235241
local path = mp.get_property('path')
236242
if path and path:find('^https?://') then
237-
if path:find('youtube%.com') or path:find('youtu%.be') then
243+
if path:find('youtube%.com') or
244+
path:find('youtu%.be') then
238245
RPC.activity.assets.large_image = 'youtube'
239246
elseif path:find('twitch%.tv') then
240247
RPC.activity.assets.large_image = 'twitch'
248+
elseif path:find('cdn%.discordapp%.com') or
249+
path:find('media%.discordapp%.net') then
250+
RPC.activity.assets.large_image = 'discord'
251+
elseif path:find('drive%.google%.') then
252+
RPC.activity.assets.large_image = 'drive'
241253
elseif path:find('twitter%.com') then
242254
RPC.activity.assets.large_image = 'twitter'
243-
elseif path:find('discordapp%.com') or
244-
path:find('discordapp%.net') then
245-
RPC.activity.assets.large_image = 'discord'
246-
elseif path:find('yewtu%.be') or
247-
path:find('invidious%.snopyta%.org') or
248-
path:find('vid%.mint%.lgbt') then
255+
elseif path:find('reddit%.com') or
256+
path:find('redd%.it') then
257+
RPC.activity.assets.large_image = 'reddit'
258+
elseif path:find(o.invidious) then
249259
RPC.activity.assets.large_image = 'invidious'
260+
elseif path:find(o.piped) then
261+
RPC.activity.assets.large_image = 'piped'
262+
elseif path:find(o.nitter) then
263+
RPC.activity.assets.large_image = 'nitter'
264+
elseif path:find(o.libreddit) then
265+
RPC.activity.assets.large_image = 'libreddit'
250266
else
251267
RPC.activity.assets.large_image = 'stream'
252268
end

0 commit comments

Comments
 (0)