Compare commits

..

No commits in common. "9c8203d4330c6b3b72700cfab21578f3ce88090c" and "c1439ca4c5bed6d95e82048c8d1b7c55c46e2596" have entirely different histories.

3 changed files with 9 additions and 18 deletions

View File

@ -11,11 +11,11 @@ from . import Plugin
from .utils import re_generator from .utils import re_generator
GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring GNU_LINUX = """I'd Just Like To Interject For A Moment. What you're referring
to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it,
GNU plus Linux. Linux is not an operating system unto itself, but rather GNU plus Linux. Linux is not an operating system unto itself, but rather
another free component of a fully functioning GNU system made useful by the another free component of a fully functioning GNU system made useful by the
GNU corelibs, shell utilities and vital system components comprising a full GNU corelibs, shell utilities and vital system components comprising a full
OS as defined by POSIX.""" OS as defined by POSIX."""
class Linux(Plugin): class Linux(Plugin):

View File

@ -49,8 +49,8 @@ class McManiac(DatabasePlugin):
if result: if result:
return '[{rank}/{total}] {item}'.format(**result) return '[{rank}/{total}] {item}'.format(**result)
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG (?P<channel>#\S+) :.*?\b(?P<item>Mc\S+iaC)\b.*') @irc3.event(r'^:(?P<mask>\S+) PRIVMSG \S+ :.*?\b(?P<item>Mc\S+iaC)\b.*')
def save(self, mask: str, channel: str, item: str): def save(self, mask: str, item: str):
if IrcString(mask).nick != self.bot.nick: if IrcString(mask).nick != self.bot.nick:
with self.con.cursor() as cur: with self.con.cursor() as cur:
cur.execute(''' cur.execute('''
@ -59,11 +59,5 @@ class McManiac(DatabasePlugin):
VALUES VALUES
(%s) (%s)
ON CONFLICT DO NOTHING ON CONFLICT DO NOTHING
RETURNING
(SELECT (count(*) + 1) AS total FROM mcmaniacs)
''', [item]) ''', [item])
self.con.commit() self.con.commit()
result = cur.fetchone()
if result is None:
return
self.bot.privmsg(channel, f"{result['total']}. mcmanic added: {item}")

View File

@ -16,7 +16,6 @@ class YouTube(Plugin):
URL = 'https://www.googleapis.com/youtube/v3' URL = 'https://www.googleapis.com/youtube/v3'
API = '{}/videos?part=snippet,statistics,contentDetails'.format(URL) API = '{}/videos?part=snippet,statistics,contentDetails'.format(URL)
SEARCH = '{}/search?part=id'.format(URL) SEARCH = '{}/search?part=id'.format(URL)
RETURN_YOUTUBE_DISLIKE_API = 'https://returnyoutubedislikeapi.com/votes'
def get_video_data(self, video_id: str): def get_video_data(self, video_id: str):
"""Requests the infos for a video id and formats them.""" """Requests the infos for a video id and formats them."""
@ -25,15 +24,13 @@ class YouTube(Plugin):
if not data.get('items'): if not data.get('items'):
return return
return_youtube_dislike_response = requests.get(self.RETURN_YOUTUBE_DISLIKE_API, params={'videoId': video_id}).json()
item = data['items'][0] item = data['items'][0]
date = date_from_iso(item['snippet']['publishedAt']) date = date_from_iso(item['snippet']['publishedAt'])
length = re.findall('(\d+[DHMS])', item['contentDetails']['duration']) length = re.findall('(\d+[DHMS])', item['contentDetails']['duration'])
views = int(item['statistics'].get('viewCount', 0)) views = int(item['statistics'].get('viewCount', 0))
likes = int(item['statistics'].get('likeCount', 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: try:
score = 100 * float(likes) / (likes + dislikes) score = 100 * float(likes) / (likes + dislikes)