Compare commits
3 Commits
c1439ca4c5
...
9c8203d433
Author | SHA1 | Date | |
---|---|---|---|
9c8203d433 | |||
9ba23e9a29 | |||
5fe240db8b |
10
bot/linux.py
10
bot/linux.py
@ -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):
|
||||||
|
@ -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 \S+ :.*?\b(?P<item>Mc\S+iaC)\b.*')
|
@irc3.event(r'^:(?P<mask>\S+) PRIVMSG (?P<channel>#\S+) :.*?\b(?P<item>Mc\S+iaC)\b.*')
|
||||||
def save(self, mask: str, item: str):
|
def save(self, mask: str, channel: 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,5 +59,11 @@ 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}")
|
||||||
|
@ -16,6 +16,7 @@ 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."""
|
||||||
@ -24,13 +25,15 @@ 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(item['statistics'].get('dislikeCount', 0))
|
dislikes = int(return_youtube_dislike_response.get('dislikes', 0))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
score = 100 * float(likes) / (likes + dislikes)
|
score = 100 * float(likes) / (likes + dislikes)
|
||||||
|
Loading…
Reference in New Issue
Block a user