Skip to content

Commit

Permalink
I represent to you all the sins you never had the courage to commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FraserChapman committed Jul 16, 2019
0 parents commit f02d4e8
Show file tree
Hide file tree
Showing 30 changed files with 863 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) 2018 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.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# plugin.video.dw

This add-on enables playing of videos and movies from the [Deutsche Welle](https://www.dw.com/) website.

* Shows Live TV such as; DW English, DW Deutsch, DW Deutsch+, DW Español and عربية DW
* Shows TV Programmes such as; Arts.21, Close Up, DocFilm, etc
* Shows topics such as; Lifestyle, Education, Science, Sports, etc
* Shows programs from the last 24 hours
* Allows searching and saved searches
* Caches recently viewed files for fast replay

## Notes on language

To view Arabic characters with the default Estuary skin you need to set the font to "Arial based"

```Settings -> Interface -> Fonts "Arial based"```

The language option in the add-on settings applies to "Search" results and items in "Last 24 hours" section - "Topic" and "Programme" text is always in English (en).

## The Collection

Deutsche Welle is Germany’s international broadcaster. It conveys a comprehensive image of Germany, reports events and developments and incorporates German and other perspectives in a journalistically independent manner.

## Disclaimer

This add-on is not created, maintained or in any way affiliated with Deutsche Welle. It only provides an interface to access the free content on the Deutsche Welle 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)

## 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?)

[Twitter - Public Domain / Fair use](https://twitter.com/DeutscheWelle)

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

[Daily Motion - Public Domain / Fair Use](https://www.dailymotion.com/video/x3rb768)

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/06fcd4045eaf4eb4982e28df04127500)](https://www.codacy.com/app/FraserChapman/plugin.video.dw?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FraserChapman/plugin.video.dw&amp;utm_campaign=Badge_Grade)
36 changes: 36 additions & 0 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.dw" name="Deutsche Welle" 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.beautifulsoup4" version="4.3.2"/>
<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 Deutsche Welle website.</summary>
<description lang="en_GB">Deutsche Welle is Germany’s international broadcaster.
Watch live TV and a range of programmes available via the DW website </description>
<language>en de es ar</language>
<platform>all</platform>
<license>MIT</license>
<forum>https://forum.kodi.tv/showthread.php?tid=345450</forum>
<website>https://www.dw.com/</website>
<email>fraser.chapman@gmail.com</email>
<source>https://github.com/FraserChapman/plugin.video.dw</source>
<news>v1.0.0 (14-7-19) - Initial version</news>
<disclaimer lang="en_GB">Neither this addon nor its author are in anyway affiliated with Deutsche Welle</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>
</assets>
</extension>
</addon>
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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: Deutsche Welle
# Addon id: plugin.video.dw
# 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 "Language"
msgstr ""

msgctxt "#32003"
msgid "!UNUSED!"
msgstr ""

msgctxt "#32004"
msgid "Past 24 hours"
msgstr ""

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

msgctxt "#32006"
msgid "Live TV"
msgstr ""

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

msgctxt "#32008"
msgid "Topics"
msgstr ""

msgctxt "#32009"
msgid "Programs"
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 "!!UNUSED!!"
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 f02d4e8

Please sign in to comment.