mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-26 04:51:09 -05:00
YouTube/SpiffyTitles: add upload date
This commit is contained in:
parent
b5d54daf93
commit
cb14316271
@ -106,7 +106,7 @@ Default value: `\x030,4 ► \x031,0YouTube`
|
|||||||
|
|
||||||
`youtube.template` - This is the template used when showing the title of a YouTube video
|
`youtube.template` - This is the template used when showing the title of a YouTube video
|
||||||
|
|
||||||
Default value: `^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} uploaded by {{channel_title}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites`
|
Default value: `^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} :: Uploader: {{channel_title}} :: Uploaded: {{published}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites`
|
||||||
|
|
||||||
Example output:
|
Example output:
|
||||||
|
|
||||||
@ -125,6 +125,7 @@ like_count | Number of likes
|
|||||||
dislike_count | Number of dislikes
|
dislike_count | Number of dislikes
|
||||||
favorite_count | Number of favorites
|
favorite_count | Number of favorites
|
||||||
comment_count | Number of comments
|
comment_count | Number of comments
|
||||||
|
published | Date uploaded
|
||||||
timestamp | If specified, the start time of the video
|
timestamp | If specified, the start time of the video
|
||||||
|
|
||||||
Tip: You can use irc colors colors in your templates, but be sure to quote the value
|
Tip: You can use irc colors colors in your templates, but be sure to quote the value
|
||||||
|
@ -195,7 +195,7 @@ conf.registerChannelValue(SpiffyTitles.youtube, 'logo',
|
|||||||
registry.String("\x030,4 ► \x031,0YouTube", _("""Logo used with {{yt_logo}} in template""")))
|
registry.String("\x030,4 ► \x031,0YouTube", _("""Logo used with {{yt_logo}} in template""")))
|
||||||
# YouTube template
|
# YouTube template
|
||||||
conf.registerChannelValue(SpiffyTitles.youtube, 'template',
|
conf.registerChannelValue(SpiffyTitles.youtube, 'template',
|
||||||
registry.String("^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} :: Uploader {{channel_title}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites :: {{comment_count}} comments", _("""Template used for YouTube title responses""")))
|
registry.String("^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} :: Uploader {{channel_title}} :: Uploaded: {{published}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites :: {{comment_count}} comments", _("""Template used for YouTube title responses""")))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -717,6 +717,9 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
duration = "LIVE"
|
duration = "LIVE"
|
||||||
|
|
||||||
|
published = snippet['publishedAt']
|
||||||
|
published = self.get_published_date(published)
|
||||||
|
|
||||||
timestamp = self.get_timestamp_from_youtube_url(url)
|
timestamp = self.get_timestamp_from_youtube_url(url)
|
||||||
yt_logo = self.get_youtube_logo()
|
yt_logo = self.get_youtube_logo()
|
||||||
|
|
||||||
@ -730,6 +733,7 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
"comment_count": comment_count,
|
"comment_count": comment_count,
|
||||||
"favorite_count": favorite_count,
|
"favorite_count": favorite_count,
|
||||||
"channel_title": channel_title,
|
"channel_title": channel_title,
|
||||||
|
"published": published,
|
||||||
"yt_logo": yt_logo
|
"yt_logo": yt_logo
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -754,6 +758,12 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
|
|
||||||
return self.handler_default(url, channel)
|
return self.handler_default(url, channel)
|
||||||
|
|
||||||
|
def get_published_date(self, date):
|
||||||
|
date = pendulum.parse(date, strict=False)
|
||||||
|
date = pendulum.datetime(date.year, date.month, date.day)
|
||||||
|
date = date.to_date_string()
|
||||||
|
return date
|
||||||
|
|
||||||
def get_duration_from_seconds(self, duration_seconds):
|
def get_duration_from_seconds(self, duration_seconds):
|
||||||
m, s = divmod(duration_seconds, 60)
|
m, s = divmod(duration_seconds, 60)
|
||||||
h, m = divmod(m, 60)
|
h, m = divmod(m, 60)
|
||||||
|
@ -58,7 +58,7 @@ conf.registerChannelValue(YouTube, 'logo',
|
|||||||
registry.String("\x02\x030,4 ► \x031,0YouTube", _("""Logo used with $yt_logo in template""")))
|
registry.String("\x02\x030,4 ► \x031,0YouTube", _("""Logo used with $yt_logo in template""")))
|
||||||
|
|
||||||
conf.registerChannelValue(YouTube, 'template',
|
conf.registerChannelValue(YouTube, 'template',
|
||||||
registry.String("{{logo}} :: {{link}} :: {{title}} :: Duration: {{duration}} :: Views: {{views}} :: Uploader: {{uploader}} :: {{likes}} likes :: {{dislikes}} dislikes :: {{favorites}} favorites :: {{comments}} comments", _("""Template used for search result replies""")))
|
registry.String("{{logo}} :: {{link}} :: {{title}} :: Duration: {{duration}} :: Views: {{views}} :: Uploader: {{uploader}} :: Uploaded: {{published}} :: {{likes}} likes :: {{dislikes}} dislikes :: {{favorites}} favorites :: {{comments}} comments", _("""Template used for search result replies""")))
|
||||||
|
|
||||||
conf.registerChannelValue(YouTube, 'useBold',
|
conf.registerChannelValue(YouTube, 'useBold',
|
||||||
registry.Boolean(True, _("""Use bold in replies""")))
|
registry.Boolean(True, _("""Use bold in replies""")))
|
||||||
|
@ -136,6 +136,12 @@ class YouTube(callbacks.Plugin):
|
|||||||
|
|
||||||
return delta.total_seconds()
|
return delta.total_seconds()
|
||||||
|
|
||||||
|
def get_published_date(self, date):
|
||||||
|
date = pendulum.parse(date, strict=False)
|
||||||
|
date = pendulum.datetime(date.year, date.month, date.day)
|
||||||
|
date = date.to_date_string()
|
||||||
|
return date
|
||||||
|
|
||||||
def get_youtube_logo(self):
|
def get_youtube_logo(self):
|
||||||
use_bold = self.registryValue("useBold", dynamic.channel)
|
use_bold = self.registryValue("useBold", dynamic.channel)
|
||||||
if use_bold:
|
if use_bold:
|
||||||
@ -226,6 +232,9 @@ class YouTube(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
duration = "LIVE"
|
duration = "LIVE"
|
||||||
|
|
||||||
|
published = snippet['publishedAt']
|
||||||
|
published = self.get_published_date(published)
|
||||||
|
|
||||||
yt_logo = self.get_youtube_logo()
|
yt_logo = self.get_youtube_logo()
|
||||||
|
|
||||||
link = "https://youtu.be/%s" % (video_id)
|
link = "https://youtu.be/%s" % (video_id)
|
||||||
@ -240,6 +249,7 @@ class YouTube(callbacks.Plugin):
|
|||||||
"favorites": favorite_count,
|
"favorites": favorite_count,
|
||||||
"uploader": channel_title,
|
"uploader": channel_title,
|
||||||
"link": link,
|
"link": link,
|
||||||
|
"published": published,
|
||||||
"logo": yt_logo
|
"logo": yt_logo
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user