"""
Copyright (C) 2018 MuadDib
----------------------------------------------------------------------------
"THE BEER-WARE LICENSE" (Revision 42):
@tantrumdev wrote this file. As long as you retain this notice you can do
whatever you want with this stuff. Just Ask first when not released through
the tools and parser GIT. If we meet some day, and you think this stuff is
worth it, you can buy him a beer in return. - Muad'Dib
----------------------------------------------------------------------------
Overview:
Drop this PY in the plugins folder. See examples below on use.
Version:
2019.7.23:
- Updated Clear Cache function to make use of "quiet_cache"
2018.7.2:
- Added Clear Cache function
- Minor update on fetch cache returns
2018.6.20:
- Added caching to primary menus (Cache time is 3 hours)
2018.5.17
- Initial Release
XML Explanations:
Tags:
- Displays the entry as category's contents
Usage Examples:
911dhcategory/911Activistdhcategory/activistArchaeologydhcategory/archaeologyArt and Artistsdhcategory/art-and-artistsAtheismdhcategory/atheismBiographiesdhcategory/biographiesBusinessdhcategory/businessCelebritydhcategory/celebrityCrimedhcategory/crimeConferencedhcategory/conferenceConspiracydhcategory/conspiracyCountriesdhcategory/countriesDrugsdhcategory/drugsEconomicsdhcategory/economicsEducationaldhcategory/educationalEnvironmentdhcategory/environmentEvolutiondhcategory/evolutionGangsdhcategory/gangsHealthdhcategory/healthHistorydhcategory/historyHuman Rightsdhcategory/human-rightsLifestyledhcategory/lifestyleMoviesdhcategory/moviesMusicdhcategory/musicMysterydhcategory/mysteryNaturedhcategory/natureNews and Politicsdhcategory/news-politicsPerforming Artsdhcategory/performing-artsPhilosophydhcategory/philosophyPreview Onlydhcategory/preview-onlyPsychologydhcategory/psychologyReligiondhcategory/religionSciencedhcategory/scienceSocietydhcategory/societySpacedhcategory/spaceSpiritualdhcategory/spiritualSport and Adventuredhcategory/sportadventureTechnologydhcategory/technologyWardhcategory/war
"""
import __builtin__
import base64,time
import json,re,requests,os,traceback,urlparse
import koding
import xbmc,xbmcaddon,xbmcgui
from koding import route
from resources.lib.plugin import Plugin
from resources.lib.util import dom_parser
from resources.lib.util.context import get_context_items
from resources.lib.util.xml import JenItem, JenList, display_list
from unidecode import unidecode
CACHE_TIME = 10800 # change to wanted cache time in seconds
addon_id = xbmcaddon.Addon().getAddonInfo('id')
addon_fanart = xbmcaddon.Addon().getAddonInfo('fanart')
addon_icon = xbmcaddon.Addon().getAddonInfo('icon')
docu_link = 'http://documentaryheaven.com'
docu_cat_list = 'http://documentaryheaven.com/category/'
"""
Add strings to the reg_items for domains that are supported naturally by resolveurl
"""
reg_items = {'vimeo','dailymotion','rutube','vid.ag','thevideobee','vidzi.tv'}
unreg_items = {'myspace','nfb.ca','snagfilms','dotsub','en.musicplayon.com','vkontakte.ru','veehd.com','liveleak.com','imdb.com','disclose.tv','videoweed.es','putlocker','vid.ag','vice.com'}
"""
Examples for unreg_items, to look into future support or if requested to fix by adding to/fixing in resolveurl
thevideobee: Music - Amy
snagfiles: Music - Jimi Hendrix the Uncut Story
dotsub: Music - The Man in the Mirror
en.musicplayon.com: Music - Prince: The Glory Years
vkontakte.ru: Music - Paul Kalkbrenner: A live documentary
veehd.com: The Abandoned Marsh
liveleak.com: Lost Nuke
imdb.com: Eceti Ranch
disclose.tv: The Revelation of the Pyramids
videoweed.es: EP2/4 Wonders of the Universe
putlocker: EP 1/6 The Private Life of Plants
vid.ag: Jim: The James Foley Story
vice.com: Our Rising Oceans
"""
class DocuHeaven(Plugin):
name = "docuh"
priority = 200
def process_item(self, item_xml):
if "" in item_xml:
item = JenItem(item_xml)
if "dhcategory/" in item.get("docuh", ""):
result_item = {
'label': item["title"],
'icon': item.get("thumbnail", addon_icon),
'fanart': item.get("fanart", addon_fanart),
'mode': "DHCats",
'url': item.get("docuh", ""),
'folder': True,
'imdb': "0",
'content': "files",
'season': "0",
'episode': "0",
'info': {},
'year': "0",
'context': get_context_items(item),
"summary": item.get("summary", None)
}
result_item['fanart_small'] = result_item["fanart"]
return result_item
def clear_cache(self):
skip_prompt = xbmcaddon.Addon().getSetting("quiet_cache")
dialog = xbmcgui.Dialog()
if skip_prompt == 'false':
if dialog.yesno(xbmcaddon.Addon().getAddonInfo('name'), "Clear Documentary Heaven Plugin Cache?"):
koding.Remove_Table("docuheaven_com_plugin")
else:
koding.Remove_Table("docuheaven_com_plugin")
@route(mode='DHCats', args=["url"])
def get_DHcats(url):
pins = ""
url = url.replace('dhcategory/', '') # Strip our category tag off.
orig_cat = url.split("/")[0]
url = urlparse.urljoin(docu_cat_list, url)
xml = fetch_from_db(url)
if not xml:
xml = ""
try:
html = requests.get(url).content
doc_list = dom_parser.parseDOM(html, 'article')
for content in doc_list:
try:
docu_info = re.compile('