Skip to content

Commit

Permalink
Storytelling reveals meaning without committing the error of defining it
Browse files Browse the repository at this point in the history
  • Loading branch information
FraserChapman committed Jul 12, 2019
0 parents commit a6508b7
Show file tree
Hide file tree
Showing 31 changed files with 800 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyo
.idea
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 Fraser Chapman <fraser.chapman@gmail.com> (https://github.com/FraserChapman)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# plugin.video.loc

This add-on enables playing of videos and movies from the [Library of Congress](https://www.loc.gov/) website.

* Shows collections such as; National Book Festivals, American Folklife Center, Event Videos, etc
* Shows collections by; Contributor, Subject, Location, etc
* Allows searching the archive and saved searches
* Caches recently viewed files for fast replay

[Donations for this add-on gratefully accepted](https://www.paypal.me/fraserchapman)

## The Collection

The Library of Congress is the largest library in the world, with millions of books, recordings, photographs, newspapers, maps and manuscripts in its collections.
The Library is the main research arm of the U.S. Congress and the home of the U.S. Copyright Office.
Several thousand clips, videos and early motion pictures are viewable from the Library's Digital Collection.

## Disclaimer

This add-on is not created, maintained or in any way affiliated with the Library of Congress.
It only provides an interface to access the free content on the Library of Congress website from Kodi.

## Screen Shots

![ss1](resources/media/ss1.jpg)
![ss2](resources/media/ss2.jpg)
![ss3](resources/media/ss3.jpg)
![ss3](resources/media/ss4.jpg)
![ss3](resources/media/ss5.jpg)
![ss3](resources/media/ss6.jpg)

## Licence

All art work, code and data is provided under an [MIT License](LICENSE.txt)

Except the two images icon.png and fanart.jpg

![icon.png](resources/icon.png)

[Library of Congress - Fair use](https://www.loc.gov/)

![fanart.jpg](resources/fanart.jpg)

[10wallpaper - Fair Use](https://www.10wallpaper.com/view/Washington_Library_of_Congress-2017_Bing_Desktop_Wallpapers.html)

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/56607a2f1c5e4b139919c3c2108f5d16)](https://www.codacy.com/app/FraserChapman/plugin.video.loc?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FraserChapman/plugin.video.loc&amp;utm_campaign=Badge_Grade)
39 changes: 39 additions & 0 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.loc" name="Library of Congress" version="1.0.0" provider-name="fraser">
<requires>
<import addon="xbmc.python" version="2.26.0"/>
<import addon="script.module.routing" version="0.2.0"/>
<import addon="script.module.requests" version="2.12.4"/>
<import addon="script.module.cache" version="1.0.1"/>
</requires>
<extension point="xbmc.python.pluginsource" library="main.py">
<provides>video</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">Search and play free content from the Library of Congress</summary>
<description lang="en_GB">The Library is the main research arm of the U.S. Congress and the home of the U.S. Copyright Office.
Several thousand clips, videos and early motion pictures are viewable from the Library's Digital Collection.
</description>
<language>en</language>
<platform>all</platform>
<license>MIT</license>
<forum>https://forum.kodi.tv/showthread.php?tid=345338</forum>
<website>https://www.loc.gov/</website>
<email>fraser.chapman@gmail.com</email>
<source>https://github.com/FraserChapman/plugin.video.loc</source>
<news>v1.0.0 (11-7-19) - Initial version</news>
<disclaimer lang="en_GB">Neither this addon nor its author are in anyway affiliated with the Library of
Congress
</disclaimer>
<assets>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
<screenshot>resources/media/ss1.jpg</screenshot>
<screenshot>resources/media/ss2.jpg</screenshot>
<screenshot>resources/media/ss3.jpg</screenshot>
<screenshot>resources/media/ss4.jpg</screenshot>
<screenshot>resources/media/ss5.jpg</screenshot>
<screenshot>resources/media/ss6.jpg</screenshot>
</assets>
</extension>
</addon>
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
v1.0.0
- Initial version
5 changes: 5 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-

from resources.lib import plugin

plugin.run()
Empty file added resources/__init__.py
Empty file.
Binary file added resources/fanart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Kodi Media Center language file
# Addon Name: Library of Congress
# Addon id: plugin.video.loc
# Addon Provider: fraser
msgid ""
msgstr ""
"Project-Id-Version: XBMC Addons\n"
"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Kodi Translation Team\n"
"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgctxt "#32000"
msgid "General"
msgstr ""

msgctxt "#32001"
msgid "Debug"
msgstr ""

msgctxt "#32002"
msgid "Contributor"
msgstr ""

msgctxt "#32003"
msgid "Colour"
msgstr ""

msgctxt "#32004"
msgid "Subject"
msgstr ""

msgctxt "#32005"
msgid "Recent"
msgstr ""

msgctxt "#32006"
msgid "Years"
msgstr ""

msgctxt "#32007"
msgid "Search"
msgstr ""

msgctxt "#32008"
msgid "Fiction"
msgstr ""

msgctxt "#32009"
msgid "Location"
msgstr ""

msgctxt "#32010"
msgid "Settings"
msgstr ""

msgctxt "#32011"
msgid "Page"
msgstr ""

msgctxt "#32012"
msgid "Menu"
msgstr ""

msgctxt "#32013"
msgid "Results per-page"
msgstr ""

msgctxt "#32014"
msgid "Clear Recently Viewed"
msgstr ""

msgctxt "#32015"
msgid "Clear Searches"
msgstr ""

msgctxt "#32016"
msgid "New Search"
msgstr ""

msgctxt "#32017"
msgid "Cache"
msgstr ""

msgctxt "#32018"
msgid "Clear Cache"
msgstr ""

msgctxt "#32019"
msgid "Remove Search"
msgstr ""

msgctxt "#32020"
msgid "Save Searches"
msgstr ""

msgctxt "#32021"
msgid "Part of"
msgstr ""

msgctxt "#32022"
msgid "Are you sure?"
msgstr ""
Empty file added resources/lib/__init__.py
Empty file.
42 changes: 42 additions & 0 deletions resources/lib/kodilogging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-

import logging

import xbmc
import xbmcaddon

from resources.lib.kodiutils import get_setting_as_bool


class KodiLogHandler(logging.StreamHandler):

def __init__(self):
logging.StreamHandler.__init__(self)
addon_id = xbmcaddon.Addon().getAddonInfo("id")
formatter = logging.Formatter("[{}] %(name)s %(message)s".format(addon_id))
self.setFormatter(formatter)

def emit(self, record):
levels = {
logging.CRITICAL: xbmc.LOGFATAL,
logging.ERROR: xbmc.LOGERROR,
logging.WARNING: xbmc.LOGWARNING,
logging.INFO: xbmc.LOGINFO,
logging.DEBUG: xbmc.LOGDEBUG,
logging.NOTSET: xbmc.LOGNONE,
}
if get_setting_as_bool("debug"):
try:
xbmc.log(self.format(record), levels[record.levelno])
except UnicodeEncodeError:
xbmc.log(self.format(record).encode(
"utf-8", "ignore"), levels[record.levelno])

def flush(self):
pass


def config():
logger = logging.getLogger()
logger.addHandler(KodiLogHandler())
logger.setLevel(logging.DEBUG)
92 changes: 92 additions & 0 deletions resources/lib/kodiutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-

"""Kodi gui and settings helpers"""

__author__ = "fraser"

import os

import xbmc
import xbmcaddon
import xbmcgui

ADDON = xbmcaddon.Addon()
ADDON_NAME = ADDON.getAddonInfo("name")
ADDON_PATH = ADDON.getAddonInfo("path")
MEDIA_URI = os.path.join(ADDON_PATH, "resources", "media")


def art(image):
# type: (str) -> dict
return {
"icon": image,
"thumb": image,
"fanart": image,
"poster": image
}


def icon(image):
# type: (str) -> dict
"""Creates the application folder icon info for main menu items"""
return {"icon": os.path.join(MEDIA_URI, image)}


def user_input():
# type: () -> Union[str, bool]
keyboard = xbmc.Keyboard("", "{} {}".format(localize(32007), ADDON_NAME)) # search
keyboard.doModal()
if keyboard.isConfirmed():
return keyboard.getText()
return False


def confirm():
# type: () -> bool
return xbmcgui.Dialog().yesno(ADDON_NAME, localize(32022)) # Are you sure?


def notification(header, message, time=5000, image=ADDON.getAddonInfo("icon"), sound=True):
# type: (str, str, int, str, bool) -> None
xbmcgui.Dialog().notification(header, str(message), image, time, sound)


def show_settings():
# type: () -> None
ADDON.openSettings()


def get_setting(setting):
# type: (str) -> str
return ADDON.getSetting(setting).strip()


def set_setting(setting, value):
# type: (str, Any) -> None
ADDON.setSetting(setting, str(value))


def get_setting_as_bool(setting):
# type: (str) -> bool
return ADDON.getSettingBool(setting)


def get_setting_as_float(setting):
# type: (str) -> float
try:
return ADDON.getSettingNumber(setting)
except ValueError:
return 0


def get_setting_as_int(setting):
# type: (str) -> int
try:
return ADDON.getSettingInt(setting)
except ValueError:
return 0


def localize(token):
# type: (int) -> str
return ADDON.getLocalizedString(token).encode("utf-8", "ignore").decode("utf-8")
Loading

0 comments on commit a6508b7

Please # to comment.