Skip to content

Commit

Permalink
Fixed nzbmatrix category id and added a few minor features
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dlesk committed Jan 13, 2012
1 parent c86d5a0 commit 670de66
Show file tree
Hide file tree
Showing 16 changed files with 380 additions and 52 deletions.
18 changes: 15 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,29 @@ Examples:
  &Anbsp;Search for games that contain "Super" and are only for the Wii: http://127.0.0.1:8085/api?api_key=ikzFRzA1Y8I1UajNJAOQ803TbTYk1vLB64A9SxrAxAw&mode=search&term=super&system=wii

***GETREQUESTED***
To Be Added
<br />
***ADDREQUESTED***
To Be Added
<br /><br />
***ADDREQUESTED***
<br />
***DELETEREQUESTED***
To Be Added
<br /><br />
***DELETEREQUESTED***
<br />
To Be Added
<br /><br />
***UPDATEREQUESTEDSTATUS***
<br />
To Be Added
<br /><br />
***SEARCHUPCOMING***
<br />
To Be Added
<br /><br />
***ADDUPCOMINGTOREQUESTED***
<br />
To Be Added
<br /><br />
***UPDATEGAMELIST***
<br />
This mode updates the Game List in Gamez from the Gamez.org web service. A json response will be returned with either an error or success message. No additional parameters are needed.
Expand Down
Binary file modified Gamez.db
Binary file not shown.
50 changes: 32 additions & 18 deletions Gamez.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[global]
server.socket_host = "127.0.0.1"
server.socket_port = 8085
user_name = ""
password = ""
user_name =
password =

[NZBMatrix]
username = ""
api_key = ""
username =
api_key =

[Newznab]
api_key = ""
api_key =
wii_category_id = "1030"
xbox360_category_id = "1050"
host = ""
host =
port =

[Sabnzbd]
api_key = ""
api_key =
host = "127.0.0.1"
port = 8081
category = ""
category =

[Scheduler]
download_interval = 5
download_interval = 900
game_list_update_interval = 86400

[SystemGenerated]
Expand All @@ -36,18 +36,32 @@ prowl_enabled = 0
growl_enabled = 0
notifo_enabled = 0
blackhole_nzb_enabled = 0
blackhole_torrent_enabled = 1
torrent_kat_enabled = 1
blackhole_torrent_enabled = 0
torrent_kat_enabled = 0
default_search = "Wii"
process_torrent_download_folder_enabled = 0
process_nzb_download_folder_enabled = 0
process_sabnzbd_download_folder_enabled = 0
process_download_folder_wii_enabled = 0
process_download_folder_xbox360_enabled = 0
nzb_completed = 0

[Notifications]
prowl_api = ""
growl_host = ""
prowl_api =
growl_host =
growl_port = 23053
growl_password = ""
notifo_username = ""
notifo_apikey = ""
growl_password =
notifo_username =
notifo_apikey =

[Blackhole]
nzb_blackhole_path = ""
torrent_blackhole_path = ""
nzb_blackhole_path =
torrent_blackhole_path =

[Folders]
torrent_completed = ""
nzb_completed = ""
sabnzbd_completed = ""
wii_destination =
xbox360_destination =

17 changes: 16 additions & 1 deletion Gamez.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,24 @@ def RunGameListUpdaterTask():

if __name__ == '__main__':
app_path = sys.path[0]
LogEvent("Checking DB")
ValidateDB()
LogEvent("Checking config file for completeness")
CheckConfigForAllKeys(app_path)
config = ConfigParser.RawConfigParser()
configFilePath = os.path.join(app_path,'Gamez.ini')
config.read(configFilePath)
sabnzbdHost = config.get('Sabnzbd','host').replace('"','')
sabnzbdPort = config.get('Sabnzbd','port').replace('"','')
sabnzbdApi = config.get('Sabnzbd','api_key').replace('"','')
LogEvent("Attempting to get download completed directory from Sabnzbd")
sabCompleted = lib.GameTasks.GameTasks().CheckSabDownloadPath(sabnzbdApi,sabnzbdHost,sabnzbdPort)
if(sabCompleted <> ""):
LogEvent("Setting Value")
config.set('Folders','sabnzbd_completed','"' + sabCompleted + '"')
LogEvent("Trying to save")
with open(configFilePath,'wb') as configFile:
config.write(configFile)
LogEvent("Checking config file for completeness")
isToDaemonize = 0
params = sys.argv
for param in params:
Expand Down
4 changes: 2 additions & 2 deletions css/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ div#menu ul ul {
left: -999em;
width: 163px;
padding: 5px 0 0 0;
background: rgb(45,45,45);
background: #99B4FF;
margin-top:1px;
}
div#menu ul ul a {
Expand All @@ -103,7 +103,7 @@ div#menu ul ul a {
float: none;
display: block;
line-height: 24px;
color: rgb(169,169,169);
color: Green;
}
div#menu ul ul span {
margin-top: 0;
Expand Down
Binary file added css/navigation_images/no-cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 49 additions & 1 deletion lib/ConfigFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def CheckConfigForAllKeys(app_path):
if(config.has_section('Notifications') == False):
config.add_section('Notifications')
changesMade = True


if(config.has_section('Folders') == False):
config.add_section('Folders')
changesMade = True

if(config.has_option('global','server.socket_host') == False):
config.set('global','server.socket_host','"127.0.0.1"')
changesMade = True
Expand Down Expand Up @@ -134,6 +138,30 @@ def CheckConfigForAllKeys(app_path):
config.set('SystemGenerated','torrent_kat_enabled','0')
changesMade = True

if(config.has_option('SystemGenerated','process_torrent_download_folder_enabled') == False):
config.set('SystemGenerated','process_torrent_download_folder_enabled','0')
changesMade = True

if(config.has_option('SystemGenerated','process_nzb_download_folder_enabled') == False):
config.set('SystemGenerated','process_nzb_download_folder_enabled','0')
changesMade = True

if(config.has_option('SystemGenerated','process_sabnzbd_download_folder_enabled') == False):
config.set('SystemGenerated','process_sabnzbd_download_folder_enabled','0')
changesMade = True

if(config.has_option('SystemGenerated','process_download_folder_wii_enabled') == False):
config.set('SystemGenerated','process_download_folder_wii_enabled','0')
changesMade = True

if(config.has_option('SystemGenerated','process_download_folder_xbox360_enabled') == False):
config.set('SystemGenerated','process_download_folder_xbox360_enabled','0')
changesMade = True

if(config.has_option('SystemGenerated','default_search') == False):
config.set('SystemGenerated','default_search','"---"')
changesMade = True

if(config.has_option('SystemGenerated','api_key') == False):
apiKey = base64.b64encode(hashlib.sha256( str(random.getrandbits(256)) ).digest(), random.choice(['rA','aZ','gQ','hH','hG','aR','DD'])).rstrip('==')
config.set('SystemGenerated','api_key','"' + apiKey + '"')
Expand Down Expand Up @@ -191,6 +219,26 @@ def CheckConfigForAllKeys(app_path):
config.set('Blackhole','torrent_blackhole_path','""')
changesMade = True

if(config.has_option('Folders','torrent_blackhole_path') == False):
config.set('Folders','torrent_completed','""')
changesMade = True

if(config.has_option('Folders','torrent_blackhole_path') == False):
config.set('Folders','nzb_completed','""')
changesMade = True

if(config.has_option('Folders','torrent_blackhole_path') == False):
config.set('Folders','sabnzbd_completed','""')
changesMade = True

if(config.has_option('Folders','wii_destination') == False):
config.set('Folders','wii_destination','""')
changesMade = True

if(config.has_option('Folders','xbox360_destination') == False):
config.set('Folders','xbox360_destination','""')
changesMade = True

if(changesMade):
with open(configFilePath,'wb') as configFile:
config.write(configFile)
Binary file modified lib/ConfigFunctions.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/Constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def VersionNumber():
return "1.1.12.0"
return "1.1.13.0"
Binary file modified lib/Constants.pyc
Binary file not shown.
36 changes: 31 additions & 5 deletions lib/DBFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,34 @@ def AddGameToDb(db_id,status):
cursor.close()
return

def GetRequestedGames():
def AddGameUpcomingToDb(db_id,status):
LogEvent("Adding game in 'Wanted' status")
db_path = os.path.join(os.path.abspath(""),"Gamez.db")
sql = "select GameTitle,system from comingsoon where ID = '" + db_id + "'"
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
cursor.execute(sql)
result = cursor.fetchall()[0]
game_name = str(result[0])
system = str(result[1])
game_type = "Game"
cover = "/css/navigation_images/no-cover.jpg"
cursor.close()
sql = "insert into requested_games(GAME_NAME,SYSTEM,GAME_TYPE,status,cover) values('" + game_name.replace("'","''") + "','" + system + "','" + game_type + "','" + status + "','" + cover + "')"
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
cursor.execute(sql)
connection.commit()
cursor.close()
return
comingsoon

def GetRequestedGames(filter=''):
db_path = os.path.join(os.path.abspath(""),"Gamez.db")
sql = "SELECT id,game_name,game_type,status,system,cover FROM requested_games order by game_name asc"
if(filter <> ''):
sql = "SELECT id,game_name,game_type,status,system,cover FROM requested_games Where status='" + filter + "' order by game_name asc"
else:
sql = "SELECT id,game_name,game_type,status,system,cover FROM requested_games order by game_name asc"
data = ''
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
Expand Down Expand Up @@ -137,7 +162,7 @@ def UpdateStatus(game_id,status):
game_name = str(record[0])
system = str(record[1])
cursor.close()
sql = "update requested_games set status='" + status + "' where game_name = '" + game_name + "' and system = '" + system + "'"
sql = "update requested_games set status='" + status + "' where game_name = '" + game_name.replace("'","''") + "' and system = '" + system + "'"
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
cursor.execute(sql)
Expand Down Expand Up @@ -440,7 +465,7 @@ def AddComingSoonGames():

def GetUpcomingGames():
db_path = os.path.join(os.path.abspath(""),"Gamez.db")
sql = "SELECT gametitle,strftime('%m/%d/%Y',releasedate),system FROM comingsoon order by releasedate asc"
sql = "SELECT gametitle,strftime('%m/%d/%Y',releasedate),system,id FROM comingsoon order by releasedate asc"
data = ''
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
Expand All @@ -451,7 +476,8 @@ def GetUpcomingGames():
gametitle = str(record[0])
releasedate = str(record[1])
system = str(record[2])
rowdata = "<tr><td>" + gametitle + "</td><td>" + releasedate + "</td><td>" + system + "</td></tr>"
db_id = str(record[3])
rowdata = "<tr><td><a href='addgameupcoming?dbid=" + db_id + "'>Download</a></td><td>" + gametitle + "</td><td>" + releasedate + "</td><td>" + system + "</td></tr>"
data = data + rowdata
except:
continue
Expand Down
Binary file modified lib/DBFunctions.pyc
Binary file not shown.
19 changes: 16 additions & 3 deletions lib/GameTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def FindGameOnNZBMatrix(self,game_name,game_id,username,api,sabnzbdApi,sabnzbdHo
else:
LogEvent("Unrecognized System")
return False
LogEvent(catToUse)
url = "http://api.nzbmatrix.com/v1.1/search.php?search=" + game_name + "&num=1&cat=" + catToUse + "&username=" + username + "&apikey=" + api
url = "http://api.nzbmatrix.com/v1.1/search.php?search=" + game_name + "&num=1&catid=" + catToUse + "&username=" + username + "&apikey=" + api

try:
opener = urllib.FancyURLopener({})
Expand Down Expand Up @@ -194,11 +193,25 @@ def DownloadTorrent(self,torrentUrl,title,torrentBlackholePath):
return False
return True

def CheckSabDownloadPath(self,sabnzbdApi,sabnzbdHost,sabnzbdPort):
url = "http://" + sabnzbdHost + ":" + sabnzbdPort + "/sabnzbd/api?mode=get_config&apikey=" + sabnzbdApi + "&section=misc&keyword=complete_dir"
try:
opener = urllib.FancyURLopener({})
responseObject = opener.open(url)
response = responseObject.read()
responseObject.close()
completedDir = response.split(":")[2].replace("'","").replace(" ","").replace("{","").replace("}","").replace("\n","")
return completedDir
except:
LogEvent("Unable to get Sab Download Complete Directory")
return ""
return

def CheckIfPostProcessExistsInSab(self,sabnzbdApi,sabnzbdHost,sabnzbdPort):

path = os.path.abspath("postprocess")
srcPath = os.path.join(path,"gamezPostProcess.py")
url = "http://" + sabnzbdHost + ":" + sabnzbdPort + "/sabnzbd/api?mode=get_config&apikey=" + sabnzbdApi + "&section=misc&keyword=script_dir"
url = urllib.quote("http://" + sabnzbdHost + ":" + sabnzbdPort + "/sabnzbd/api?mode=get_config&apikey=" + sabnzbdApi + "&section=misc&keyword=script_dir")
try:
opener = urllib.FancyURLopener({})
responseObject = opener.open(url)
Expand Down
Binary file modified lib/GameTasks.pyc
Binary file not shown.
Loading

0 comments on commit 670de66

Please sign in to comment.