Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #144 from cliffordwhansen/master
Browse files Browse the repository at this point in the history
A couple of new settings
  • Loading branch information
Manromen committed May 31, 2012
2 parents 17ef66c + ff6cc1c commit 1e59d75
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1 +1,2 @@
*.pyo
*.pyo
*.pyc
9 changes: 7 additions & 2 deletions friends.py
Expand Up @@ -15,12 +15,17 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '48dfcb4813134da82152984e8c4f329bc8b8b46a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
https = __settings__.getSetting( "https" )

if (https == 'true'):
conn = httplib.HTTPSConnection('api.trakt.tv')
else:
conn = httplib.HTTPConnection('api.trakt.tv')

conn = httplib.HTTPConnection('api.trakt.tv')
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

def showFriends():
Expand Down
65 changes: 65 additions & 0 deletions nbhttpsconnection.py
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
#

import os, sys
import time, socket
import urllib
import thread
import threading

try:
# Python 3.0 +
import http.client as httplib
except ImportError:
# Python 2.7 and earlier
import httplib

try:
# Python 2.6 +
from hashlib import sha as sha
except ImportError:
# Python 2.5 and earlier
import sha

__author__ = "Ralph-Gordon Paul, Adrian Cowan"
__credits__ = ["Ralph-Gordon Paul", "Adrian Cowan", "Justin Nemeth", "Sean Rudford"]
__license__ = "GPL"
__maintainer__ = "Ralph-Gordon Paul"
__email__ = "ralph-gordon.paul@uni-duesseldorf.de"
__status__ = "Production"

# Allows non-blocking http requests
class NBHTTPSConnection():
def __init__(self, host, port = None, strict = None, timeout = None):
self.rawConnection = httplib.HTTPSConnection(host, port, strict, timeout)
self.responce = None
self.responceLock = threading.Lock()
self.closing = False

def request(self, method, url, body = None, headers = {}):
self.rawConnection.request(method, url, body, headers);

def hasResult(self):
if self.responceLock.acquire(False):
self.responceLock.release()
return True
else:
return False

def getResult(self):
while not self.hasResult() and not self.closing:
time.sleep(1)
return self.responce

def go(self):
self.responceLock.acquire()
thread.start_new_thread ( NBHTTPSConnection._run, ( self, ) )

def _run(self):
self.responce = self.rawConnection.getresponse()
self.responceLock.release()

def close(self):
self.closing = True
self.rawConnection.close()

2 changes: 1 addition & 1 deletion rating.py
Expand Up @@ -16,7 +16,7 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '0a698a20b222d0b8637298f6920bf03a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
Expand Down
9 changes: 7 additions & 2 deletions recommend.py
Expand Up @@ -15,12 +15,17 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '48dfcb4813134da82152984e8c4f329bc8b8b46a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
https = __settings__.getSetting('https')

if (https == 'true'):
conn = httplib.HTTPSConnection('api.trakt.tv')
else:
conn = httplib.HTTPConnection('api.trakt.tv')

conn = httplib.HTTPConnection('api.trakt.tv')
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

# list reccomended movies
Expand Down
2 changes: 2 additions & 0 deletions resources/language/Dutch/string.xml
Expand Up @@ -6,6 +6,8 @@
<string id="1012">API Key (te vinden op trakt -&gt; Settings -&gt; API)</string>
<string id="1013">Gebruikersnaam</string>
<string id="1014">Wachtwoord</string>
<string id="1015">API Key</string>
<string id="1016">HTTPS</string>

<string id="1020">Automatisch synchroniseren</string>
<string id="1021">Automatisch bijwerken Film Collectie bij opstarten</string>
Expand Down
2 changes: 2 additions & 0 deletions resources/language/English/strings.xml
Expand Up @@ -6,6 +6,8 @@
<string id="1012">API Key (found on trakt --&gt; Settings --&gt; API)</string>
<string id="1013">Username</string>
<string id="1014">Password</string>
<string id="1015">API Key</string>
<string id="1016">HTTPS</string>

<string id="1020">Auto Syncing</string>
<string id="1021">Auto update Movies Collection at startup</string>
Expand Down
2 changes: 2 additions & 0 deletions resources/language/German/strings.xml
Expand Up @@ -5,6 +5,8 @@
<string id="1002">API Key</string>
<string id="1003">Benutzername</string>
<string id="1004">Passwort</string>
<string id="1015">API Key</string>
<string id="1016">HTTPS</string>
<string id="1005">Aktualisiere Filmsammlung beim start</string>
<string id="1006">Aktualisiere Seriensammlung beim start</string>
<string id="1007">Synchronisiere gesehene Filme beim start</string>
Expand Down
2 changes: 2 additions & 0 deletions resources/language/Polish/strings.xml
Expand Up @@ -10,6 +10,8 @@
<string id="1012">Klucz API (dostępny na trakt --&gt; Ustawienia --&gt; API)</string>
<string id="1013">Użytkownik</string>
<string id="1014">Hasło</string>
<string id="1015">Klucz API</string>
<string id="1016">HTTPS</string>
<string id="1020">Auto synchronizacja</string>
<string id="1021">Auto aktualizacja Kolekcji Filmów przy starcie</string>
<string id="1022">Auto aktualizacja Kolekcji Seriali przy starcie</string>
Expand Down
2 changes: 2 additions & 0 deletions resources/language/Portuguese (Brazil)/strings.xml
Expand Up @@ -6,6 +6,8 @@
<string id="1012">Chave API (encontre em trakt --&gt; Settings --&gt; API)</string>
<string id="1013">Usuário</string>
<string id="1014">Senha</string>
<string id="1015">Chave API</string>
<string id="1016">HTTPS</string>

<string id="1020">Auto Sincronia</string>
<string id="1021">Auto atualizar Coleção de Filmes ao iniciar</string>
Expand Down
2 changes: 2 additions & 0 deletions resources/settings.xml
Expand Up @@ -3,7 +3,9 @@
<category label="1010"><!-- General -->
<setting id="username" type="text" label="1013" default="" />
<setting id="password" type="text" option="hidden" label="1014" default="" />
<setting id="apikey" type="text" label="1015" default="" />
<setting id="debug" type="bool" label="1011" default="false"/>
<setting id="https" type="bool" label="1016" default="false"/>
</category>
<category label="1020"><!-- Auto Sync -->
<setting id="autosync_moviecollection" type="bool" label="1021" default="false"/>
Expand Down
2 changes: 1 addition & 1 deletion scrobbler.py
Expand Up @@ -20,7 +20,7 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '0a698a20b222d0b8637298f6920bf03a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
Expand Down
2 changes: 1 addition & 1 deletion sync_update.py
Expand Up @@ -31,7 +31,7 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '48dfcb4813134da82152984e8c4f329bc8b8b46a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
Expand Down
9 changes: 7 additions & 2 deletions trending.py
Expand Up @@ -35,12 +35,17 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '48dfcb4813134da82152984e8c4f329bc8b8b46a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
https = __settings__.getSetting('https')

if (https == 'true'):
conn = httplib.HTTPSConnection('api.trakt.tv')
else:
conn = httplib.HTTPConnection('api.trakt.tv')

conn = httplib.HTTPConnection('api.trakt.tv')
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

def showTrendingMovies():
Expand Down
9 changes: 7 additions & 2 deletions utilities.py
Expand Up @@ -9,6 +9,7 @@
except ImportError: import json

from nbhttpconnection import *
from nbhttpsconnection import *

import urllib, re

Expand Down Expand Up @@ -37,7 +38,7 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '48dfcb4813134da82152984e8c4f329bc8b8b46a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
Expand Down Expand Up @@ -90,8 +91,12 @@ def xcp(s):

# get a connection to trakt
def getTraktConnection():
https = __settings__.getSetting('https')
try:
conn = NBHTTPConnection('api.trakt.tv')
if (https == 'true'):
conn = NBHTTPSConnection('api.trakt.tv')
else:
conn = NBHTTPConnection('api.trakt.tv')
except socket.timeout:
Debug("getTraktConnection: can't connect to trakt - timeout")
notification("Trakt Utilities", __language__(1108).encode( "utf-8", "ignore" ) + ": timeout") # can't connect to trakt
Expand Down
9 changes: 7 additions & 2 deletions watchlist.py
Expand Up @@ -35,12 +35,17 @@
__settings__ = xbmcaddon.Addon( "script.TraktUtilities" )
__language__ = __settings__.getLocalizedString

apikey = '48dfcb4813134da82152984e8c4f329bc8b8b46a'
apikey = __settings__.getSetting('apikey')
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
https = __settings__.getSetting('https')

if (https == 'true'):
conn = httplib.HTTPSConnection('api.trakt.tv')
else:
conn = httplib.HTTPConnection('api.trakt.tv')

conn = httplib.HTTPConnection('api.trakt.tv')
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

# list watchlist movies
Expand Down

0 comments on commit 1e59d75

Please sign in to comment.