Skip to content

Instantly share code, notes, and snippets.

@null-dev
Created June 21, 2020 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save null-dev/44f19625eee4d34666c028df3ba6edea to your computer and use it in GitHub Desktop.
Save null-dev/44f19625eee4d34666c028df3ba6edea to your computer and use it in GitHub Desktop.
VNDB quotes plugin for the Variety wallpaper changer
#!/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