diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..3e8e4af
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 maxcco
+
+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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..776602c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+# Denon autoMode Plugin for Kodi (service.denonAVR)
+
+## How it works
+
+Once installed in kodi, you need to setup the ip address of your Denon AVR in extension settings.
+It will run as soon as you start kodi as a service and will send a request (similar to pressing the remote button) to activate either the movie mode or the music mode.
+
+## Disclaimer
+
+This plugin is not officially commissioned/supported by Denon. The trademark "Denon" is registered by "Sound United, LLC"
+
+## License
+
+Licensed under The MIT License.
diff --git a/addon.py b/addon.py
new file mode 100644
index 0000000..26f4b61
--- /dev/null
+++ b/addon.py
@@ -0,0 +1,19 @@
+import xbmc
+import xbmcgui
+import xbmcaddon
+import xbmcvfs
+import os
+
+__addon__ = xbmcaddon.Addon()
+__cwd__ = __addon__.getAddonInfo('path')
+__profile__ = xbmc.translatePath( __addon__.getAddonInfo('profile') )
+__resource__ = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib' ) )
+
+sys.path.append (__resource__)
+
+import utils
+from service import DenonController
+
+utils.log("Service starting...")
+controler = DenonController()
+controler.runProgram()
diff --git a/addon.xml b/addon.xml
new file mode 100644
index 0000000..7a1ff71
--- /dev/null
+++ b/addon.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+ Auto switch Denon AVR mode
+ Control your Denon AVR to switch between music and movie mode following what's played in Kodi
+
+ all
+
+ resources/media/denon.png
+ resources/media/denon.png
+
+
+
diff --git a/resources/lib/__init__.py b/resources/lib/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/resources/lib/service.py b/resources/lib/service.py
new file mode 100644
index 0000000..7d081c0
--- /dev/null
+++ b/resources/lib/service.py
@@ -0,0 +1,40 @@
+import sys
+import xbmc
+import xbmcgui
+import xbmcaddon
+import utils
+
+
+class PlayerMonitor(xbmc.Player):
+
+ def __init__(self):
+ xbmc.Player.__init__(self)
+ utils.post({'cmd0':'PutSurroundMode/MOVIE', 'cmd1':'aspMainZone_WebUpdateStatus/'})
+ self.currentMode = "MOVIE"
+
+ def onPlayBackStarted(self):
+ if (self.isPlayingAudio() and self.currentMode != "MUSIC"):
+ utils.log('Changing to Music Mode', xbmc.LOGINFO)
+ body = {'cmd0':'PutSurroundMode/MUSIC', 'cmd1':'aspMainZone_WebUpdateStatus/'}
+ self.currentMode = "MUSIC"
+
+ if (self.isPlayingVideo() and self.currentMode != "MOVIE"):
+ utils.log('Changing to Music Mode', xbmc.LOGINFO)
+ body = {'cmd0':'PutSurroundMode/MOVIE', 'cmd1':'aspMainZone_WebUpdateStatus/'}
+ self.currentMode = "MOVIE"
+
+
+class DenonController():
+ player_monitor = None
+
+ def __init__(self):
+ self.player_monitor = PlayerMonitor()
+
+
+ def runProgram(self):
+ while(not xbmc.abortRequested):
+ # waiting loop
+ xbmc.sleep(500)
+
+ #clean up monitor on exit
+ del self.player_monitor
diff --git a/resources/lib/utils.py b/resources/lib/utils.py
new file mode 100644
index 0000000..d572430
--- /dev/null
+++ b/resources/lib/utils.py
@@ -0,0 +1,27 @@
+import xbmc
+import xbmcgui
+import xbmcaddon
+import requests
+import json
+
+ADDON_ID = 'service.denonavr'
+ADDON = xbmcaddon.Addon(ADDON_ID)
+CWD = ADDON.getAddonInfo('path').decode('utf-8')
+
+def log(message,loglevel=xbmc.LOGNOTICE):
+ xbmc.log(encode(ADDON_ID+ "-" + ADDON.getAddonInfo('version') + " : " + message),level=loglevel)
+
+def encode(string):
+ return string.encode('UTF-8','replace')
+
+def post(data, count_err=0):
+ ipDenon = ADDON.getSetting('ipDenon')
+ if count_err < 10:
+ try:
+ r = requests.post("http://"+ ipDenon +"/MainZone/index.put.asp", data, verify=False,timeout=2)
+ except Exception:
+ # try again
+ count_err += 1
+ return post(data, count_err)
+ else:
+ log("Can not reach the denonavr at ip : "+ ipDenon +" , please check your settings", xbmc.LOGERROR)
diff --git a/resources/media/denon.png b/resources/media/denon.png
new file mode 100644
index 0000000..6f00656
Binary files /dev/null and b/resources/media/denon.png differ
diff --git a/resources/settings.xml b/resources/settings.xml
new file mode 100644
index 0000000..0b1bb7b
--- /dev/null
+++ b/resources/settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+