mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-26 04:51:09 -05:00
SpiffyTitles/Youtube: replace duration regex
This commit is contained in:
parent
c16a94bdf8
commit
e86c8ebebb
@ -791,16 +791,16 @@ class SpiffyTitles(callbacks.Plugin):
|
||||
twitch_logo = "{0}\x0F\x02".format(self.registryValue("twitch.logo", dynamic.channel))
|
||||
else:
|
||||
twitch_logo = "{0}\x0F".format(self.registryValue("twitch.logo", dynamic.channel))
|
||||
|
||||
|
||||
return twitch_logo
|
||||
|
||||
|
||||
def get_imdb_logo(self):
|
||||
use_bold = self.registryValue("useBold", dynamic.channel)
|
||||
if use_bold:
|
||||
imdb_logo = "{0}\x0F\x02".format(self.registryValue("imdb.logo", dynamic.channel))
|
||||
else:
|
||||
imdb_logo = "{0}\x0F".format(self.registryValue("imdb.logo", dynamic.channel))
|
||||
|
||||
|
||||
return imdb_logo
|
||||
|
||||
def get_total_seconds_from_duration(self, input):
|
||||
@ -809,24 +809,8 @@ class SpiffyTitles(callbacks.Plugin):
|
||||
4 minutes and 41 seconds. This method returns the total seconds
|
||||
so that the duration can be parsed as usual.
|
||||
"""
|
||||
regex = re.compile("""
|
||||
(?P<sign> -?) P
|
||||
(?:(?P<years> \d+) Y)?
|
||||
(?:(?P<months> \d+) M)?
|
||||
(?:(?P<days> \d+) D)?
|
||||
(?: T
|
||||
(?:(?P<hours> \d+) H)?
|
||||
(?:(?P<minutes>\d+) M)?
|
||||
(?:(?P<seconds>\d+) S)?
|
||||
)?
|
||||
""", re.VERBOSE)
|
||||
duration = regex.match(input).groupdict(0)
|
||||
|
||||
delta = pendulum.duration(hours=int(duration['hours']),
|
||||
minutes=int(duration['minutes']),
|
||||
seconds=int(duration['seconds']))
|
||||
|
||||
return delta.total_seconds()
|
||||
duration = pendulum.parse(input)
|
||||
return duration.total_seconds()
|
||||
|
||||
def get_timestamp_from_youtube_url(self, url):
|
||||
"""
|
||||
|
@ -44,14 +44,6 @@ from fake_useragent import UserAgent
|
||||
from bs4 import BeautifulSoup
|
||||
from urllib.parse import urlencode, urlparse, parse_qsl
|
||||
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
_ = PluginInternationalization('YouTube')
|
||||
except ImportError:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
_ = lambda x: x
|
||||
|
||||
class YouTube(callbacks.Plugin):
|
||||
"""Queries OMDB database for information about YouTube titles"""
|
||||
threaded = True
|
||||
@ -122,24 +114,8 @@ class YouTube(callbacks.Plugin):
|
||||
4 minutes and 41 seconds. This method returns the total seconds
|
||||
so that the duration can be parsed as usual.
|
||||
"""
|
||||
regex = re.compile("""
|
||||
(?P<sign> -?) P
|
||||
(?:(?P<years> \d+) Y)?
|
||||
(?:(?P<months> \d+) M)?
|
||||
(?:(?P<days> \d+) D)?
|
||||
(?: T
|
||||
(?:(?P<hours> \d+) H)?
|
||||
(?:(?P<minutes>\d+) M)?
|
||||
(?:(?P<seconds>\d+) S)?
|
||||
)?
|
||||
""", re.VERBOSE)
|
||||
duration = regex.match(input).groupdict(0)
|
||||
|
||||
delta = pendulum.duration(hours=int(duration['hours']),
|
||||
minutes=int(duration['minutes']),
|
||||
seconds=int(duration['seconds']))
|
||||
|
||||
return delta.total_seconds()
|
||||
duration = pendulum.parse(input)
|
||||
return duration.total_seconds()
|
||||
|
||||
def get_published_date(self, date):
|
||||
date = pendulum.parse(date, strict=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user