Compare commits
No commits in common. "9c8203d4330c6b3b72700cfab21578f3ce88090c" and "c1439ca4c5bed6d95e82048c8d1b7c55c46e2596" have entirely different histories.
9c8203d433
...
c1439ca4c5
@ -49,8 +49,8 @@ class McManiac(DatabasePlugin):
|
||||
if result:
|
||||
return '[{rank}/{total}] {item}'.format(**result)
|
||||
|
||||
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG (?P<channel>#\S+) :.*?\b(?P<item>Mc\S+iaC)\b.*')
|
||||
def save(self, mask: str, channel: str, item: str):
|
||||
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG \S+ :.*?\b(?P<item>Mc\S+iaC)\b.*')
|
||||
def save(self, mask: str, item: str):
|
||||
if IrcString(mask).nick != self.bot.nick:
|
||||
with self.con.cursor() as cur:
|
||||
cur.execute('''
|
||||
@ -59,11 +59,5 @@ class McManiac(DatabasePlugin):
|
||||
VALUES
|
||||
(%s)
|
||||
ON CONFLICT DO NOTHING
|
||||
RETURNING
|
||||
(SELECT (count(*) + 1) AS total FROM mcmaniacs)
|
||||
''', [item])
|
||||
self.con.commit()
|
||||
result = cur.fetchone()
|
||||
if result is None:
|
||||
return
|
||||
self.bot.privmsg(channel, f"{result['total']}. mcmanic added: {item}")
|
||||
|
@ -16,7 +16,6 @@ class YouTube(Plugin):
|
||||
URL = 'https://www.googleapis.com/youtube/v3'
|
||||
API = '{}/videos?part=snippet,statistics,contentDetails'.format(URL)
|
||||
SEARCH = '{}/search?part=id'.format(URL)
|
||||
RETURN_YOUTUBE_DISLIKE_API = 'https://returnyoutubedislikeapi.com/votes'
|
||||
|
||||
def get_video_data(self, video_id: str):
|
||||
"""Requests the infos for a video id and formats them."""
|
||||
@ -25,15 +24,13 @@ class YouTube(Plugin):
|
||||
if not data.get('items'):
|
||||
return
|
||||
|
||||
return_youtube_dislike_response = requests.get(self.RETURN_YOUTUBE_DISLIKE_API, params={'videoId': video_id}).json()
|
||||
|
||||
item = data['items'][0]
|
||||
date = date_from_iso(item['snippet']['publishedAt'])
|
||||
length = re.findall('(\d+[DHMS])', item['contentDetails']['duration'])
|
||||
|
||||
views = int(item['statistics'].get('viewCount', 0))
|
||||
likes = int(item['statistics'].get('likeCount', 0))
|
||||
dislikes = int(return_youtube_dislike_response.get('dislikes', 0))
|
||||
dislikes = int(item['statistics'].get('dislikeCount', 0))
|
||||
|
||||
try:
|
||||
score = 100 * float(likes) / (likes + dislikes)
|
||||
|
Loading…
Reference in New Issue
Block a user