Created
June 21, 2020 05:05
-
-
Save null-dev/44f19625eee4d34666c028df3ba6edea to your computer and use it in GitHub Desktop.
VNDB quotes plugin for the Variety wallpaper changer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from variety.plugins.IQuoteSource import IQuoteSource | |
from variety.Util import Util | |
from locale import gettext as _ | |
class VNDBSource(IQuoteSource): | |
@classmethod | |
def get_info(cls): | |
return { | |
"name": "VNDB", | |
"description": _("Displays quotes from VNDB"), | |
"author": "nulldev", | |
"version": "0.1" | |
} | |
def supports_search(self): | |
return False | |
def get_random(self): | |
bs = Util.html_soup('https://vndb.org/d7') | |
qe = bs.select('#footer > a')[0] | |
quote_text = qe.text | |
vn_link = 'https://vndb.org' + qe['href'] | |
vn_bs = Util.html_soup(vn_link) | |
quote_author = vn_bs.select('.mainbox > h1')[0].text | |
r = { | |
"quote": '"' + quote_text.strip() + '"', | |
"author": '― ' + quote_author.strip(), | |
"sourceName": 'VNDB', | |
"link": vn_link | |
} | |
return [r] | |
def get_for_author(self, author): | |
return [] | |
def get_for_keyword(self, keyword): | |
return [] | |
### Read Me | |
# | |
# First be sure that fortune is installed and in your PATH | |
# Copy this file to ~/.config/variety/plugins/quotes | |
# Restart variety | |
# | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment