コード例 #1
0
ファイル: Api.py プロジェクト: carlchina/nut
def getSearch(request, response):
    o = []

    region = request.query.get('region')
    publisher = request.query.get('publisher')

    dlc = request.query.get('dlc')
    if dlc:
        dlc = int(dlc[0])

    update = request.query.get('update')
    if update:
        update = int(update[0])

    demo = request.query.get('demo')
    if demo:
        demo = int(demo[0])

    for k, t in Titles.items():
        f = t.getLatestFile()
        if f and f.hasValidTicket and (
                region == None or t.region
                in region) and (dlc == None or t.isDLC == dlc) and (
                    update == None or t.isUpdate
                    == update) and (demo == None or t.isDemo == demo) and (
                        publisher == None or t.publisher in publisher):
            o.append({
                'id': t.id,
                'name': t.name,
                'version': int(f.version) if f.version else None,
                'region': t.region,
                'size': f.getFileSize(),
                'mtime': f.getFileModified()
            })
    response.write(json.dumps(o))
コード例 #2
0
def updateVersions(force = True):
	initTitles()
	initFiles()

	i = 0
	for k,t in Titles.items():
		if force or t.version == None:
			if (t.isDLC or t.isUpdate or Config.download.base) and (not t.isDLC or Config.download.DLC) and (not t.isDemo or Config.download.demo) and (not t.isUpdate or Config.download.update) and (t.key or Config.download.sansTitleKey) and (len(titleWhitelist) == 0 or t.id in titleWhitelist) and t.id not in titleBlacklist:
				v = t.lastestVersion(True)
				Print.info("%s[%s] v = %s" % (str(t.name), str(t.id), str(v)) )
			
				i = i + 1
				if i % 20 == 0:
					Titles.save()
			
	for t in list(Titles.data().values()):
		if not t.isUpdate and not t.isDLC and t.updateId and t.updateId and not Titles.contains(t.updateId):
			u = Title()
			u.setId(t.updateId)
			
			if u.lastestVersion():
				Titles.set(t.updateId, u)
				
				Print.info("%s[%s] FOUND" % (str(t.name), str(u.id)) )
				
				i = i + 1
				if i % 20 == 0:
					Titles.save()
					
	Titles.save()
コード例 #3
0
def getFiles():
	for k, t in Titles.items():
		f = t.getLatestFile()
		if f and f.hasValidTicket:
			o.append({'id': t.id, 'name': t.name, 'version': int(f.version) if f.version else None , 'size': f.getFileSize(), 'mtime': f.getFileModified() })

	return json.dumps(o)
コード例 #4
0
def downloadAll(wait = True):
	global activeDownloads
	global status

	try:

		for k,t in Titles.items():
			if t.isUpdateAvailable() and not t.retailOnly and (t.isDLC or t.isUpdate or Config.download.base) and (not t.isDLC or Config.download.DLC) and (not t.isDemo or Config.download.demo) and (not t.isUpdate or Config.download.update) and (t.key or Config.download.sansTitleKey) and (len(titleWhitelist) == 0 or t.id in titleWhitelist) and t.id not in titleBlacklist:
				if not t.id or t.id == '0' * 16 or (t.isUpdate and t.lastestVersion() in [None, '0']):
					#Print.warning('no valid id? ' + str(t.path))
					continue
				
				if not t.lastestVersion():
					Print.info('Could not get version for ' + str(t.name))
					continue

				Titles.queue.add(t.id)
		Titles.save()
		status = Status.create(Titles.queue.size(), 'Total Download')
		startDownloadThreads()
		while wait and (not Titles.queue.empty() or sum(activeDownloads) > 0):
			time.sleep(1)
	except KeyboardInterrupt:
		pass
	except BaseException as e:
		Print.error(str(e))

	if status:
		status.close()
コード例 #5
0
def exportKeys(fileName):
	initTitles()
	with open(fileName, 'w') as f:
		f.write('id|key|version\n')
		for tid,title in Titles.items():
			if title and title.rightsId and title.key:
				f.write(str(title.rightsId) + '|' + str(title.key) + '|' + str(title.version) + '\n')
コード例 #6
0
ファイル: Api.py プロジェクト: carlchina/nut
def getTitles(request, response):
    o = []
    map = [
        'id', 'key', 'isUpdate', 'isDLC', 'isDemo', 'name', 'version',
        'region', 'baseId'
    ]
    for k, t in Titles.items():
        o.append(t.__dict__)
    response.write(json.dumps(o))
コード例 #7
0
def submitKeys():
	try:
		import blockchain
	except:
		pass
	for id, t in Titles.items():
		if t.key: #and not t.isUpdate:
			try:
				blockchain.blockchain.suggest(t.id, t.key)
			except BaseException as e:
				Print.info(str(e))
コード例 #8
0
ファイル: nut.py プロジェクト: ScuttleSE/nut
def logMissingTitles(file):
	initTitles()
	initFiles()

	f = open(file,"w", encoding="utf-8-sig")
	
	for k,t in Titles.items():
		if not t.path and not t.retailOnly and (t.isDLC or t.isUpdate or Config.download.base) and (not t.isDLC or Config.download.DLC) and (not t.isDemo or Config.download.demo) and (not t.isUpdate or Config.download.update) and (t.key or Config.download.sansTitleKey) and (len(titleWhitelist) == 0 or t.id in titleWhitelist) and t.id not in titleBlacklist:
			f.write((t.id or ('0'*16)) + '|' + (t.key or ('0'*32)) + '|' + (t.name or '') + "\r\n")
		
	f.close()
コード例 #9
0
def logMissingTitles(file):
	initTitles()
	initFiles()

	f = open(file,"w", encoding="utf-8-sig")
	
	for k,t in Titles.items():
		if t.isUpdateAvailable() and (t.isDLC or t.isUpdate or Config.download.base) and (not t.isDLC or Config.download.DLC) and (not t.isDemo or Config.download.demo) and (not t.isUpdate or Config.download.update) and (t.key or Config.download.sansTitleKey) and (len(titleWhitelist) == 0 or t.id in titleWhitelist) and t.id not in titleBlacklist:
			if not t.id or t.id == '0' * 16 or (t.isUpdate and t.lastestVersion() in [None, '0']):
				continue
			f.write((t.id or ('0'*16)) + '|' + (t.key or ('0'*32)) + '|' + (t.name or '') + "\r\n")
		
	f.close()
コード例 #10
0
ファイル: nut.py プロジェクト: ScuttleSE/nut
def downloadAll():
	initTitles()
	initFiles()

	for k,t in Titles.items():
		if not t.path and not t.retailOnly and (t.isDLC or t.isUpdate or Config.download.base) and (not t.isDLC or Config.download.DLC) and (not t.isDemo or Config.download.demo) and (not t.isUpdate or Config.download.update) and (t.key or Config.download.sansTitleKey) and (len(titleWhitelist) == 0 or t.id in titleWhitelist) and t.id not in titleBlacklist:
			if not t.id:
				print('no valid id? ' + str(t.path))
				continue
				
			if not t.lastestVersion():
				print('Could not get version for ' + t.name)
				continue
				
			print('Downloading ' + t.name + ', ' + str(t.version).lower())
			CDNSP.download_game(t.id.lower(), t.lastestVersion(), t.key, True, '', True)
コード例 #11
0
def submitKeys():
	for id, t in Titles.items():
		if t.key and t.isBase() and len(t.getFiles()) > 0:
			try:
				#blockchain.blockchain.suggest(t.id, t.key)
				if not blockchain.verifyKey(t.id, t.key):
					Print.error('Key verification failed for %s / %s' % (str(t.id), str(t.key)))
					for f in t.getFiles():
						f.hasValidTicket = False
						f.move()
			except LookupError as e:
				Print.info(str(e))
			except OSError as e:
				Print.info(str(e))
			except BaseException as e:
				Print.info(str(e))
				raise
コード例 #12
0
ファイル: nut.py プロジェクト: carlchina/nut
            blockchain.run()

        if len(sys.argv) == 1:
            scan()
            organize()
            downloadAll()

        if args.scan_dlc != None:
            initTitles()
            initFiles()
            queue = Titles.Queue()
            if len(args.scan_dlc) > 0:
                for id in args.scan_dlc:
                    queue.add(id)
            else:
                for i, k in Titles.items():
                    if not k.isDLC and not k.isUpdate and k.id:
                        queue.add(k.id)
            startDlcScan(queue)

        if args.scan_base != None:
            initTitles()
            initFiles()
            startBaseScan()

        Status.close()

    except KeyboardInterrupt:
        Config.isRunning = False
        Status.close()
    except BaseException as e: