示例#1
0
文件: __init__.py 项目: blawar/nut
def importRegion(region='US', language='en', save=True):
	if region not in Config.regionLanguages() or language not in Config.regionLanguages()[region]:
		Print.info('Could not locate %s/%s !' % (region, language))
		return False

	Hook.call("import.pre", region, language)
	regionLanguages = []

	for region2 in Config.regionLanguages():
		for language2 in Config.regionLanguages()[region2]:
			regionLanguages.append(RegionLanguage(region2, language2, region, language))

	for rl in sorted(regionLanguages):
		data = Titles.data(rl.region, rl.language)
		for nsuId in sorted(data.keys(), reverse=True):
			regionTitle = data[nsuId]
			if not regionTitle.id:
				continue

			try:
				for tid in regionTitle.ids:
					title = Titles.get(tid, None, None)
					title.importFrom(regionTitle, rl.region, rl.language, preferredRegion=region, preferredLanguage=language)
			except:
				title = Titles.get(regionTitle.id, None, None)
				title.importFrom(regionTitle, rl.region, rl.language, preferredRegion=region, preferredLanguage=language)

	Titles.loadTxtDatabases()
	Hook.call("import.post", region, language)
	if save:
		Titles.save()
示例#2
0
文件: nut.py 项目: blawar/nut
def matchDemos():
    nut.initTitles()
    nut.initFiles()
    orphans = {}

    Titles.loadTxtDatabases()

    for nsuId, titleId in Titles.nsuIdMap.items():
        for region, languages in Config.regionLanguages().items():
            for language in languages:
                if nsuId:
                    title = Titles.get(str(nsuId), region, language)
                    title.id = titleId

    for region, languages in Config.regionLanguages().items():
        for language in languages:
            for nsuId, rt in Titles.data(region, language).items():
                if rt.id:
                    continue
                orphans[nsuId] = rt.name

            Titles.saveRegion(region, language)

    for nsuId, name in orphans.items():
        print(str(nsuId) + '|' + str(name))
示例#3
0
def genTinfoilTitles():
    nut.initTitles()
    nut.initFiles()

    for region, languages in Config.regionLanguages().items():
        for language in languages:
            nut.importRegion(region, language)
            Titles.save('titledb/titles.%s.%s.json' % (region, language),
                        False)
            #Print.info('%s - %s' % (region, language))
    nut.scanLatestTitleUpdates()
    nut.export('titledb/versions.txt', ['id', 'rightsId', 'version'])
示例#4
0
文件: __init__.py 项目: blawar/nut
def refreshRegions(save=True):
	for region in Config.regionLanguages():
		for language in Config.regionLanguages()[region]:
			for i in Titles.data(region, language):
				regionTitle = Titles.data(region, language)[i]

				if regionTitle.id:
					title = Titles.get(regionTitle.id, None, None)

					if not hasattr(title, 'regions') or not title.regions:
						title.regions = []

					if not hasattr(title, 'languages') or not title.languages:
						title.languages = []

					if region not in title.regions:
						title.regions.append(region)

					if language not in title.languages:
						title.languages.append(language)
	if save:
		Titles.save()
示例#5
0
def genTinfoilTitles():
	nut.initTitles(verify=False)
	nut.initFiles(verify=False)

	nut.refreshRegions(False)

	for region, languages in Config.regionLanguages().items():
		for language in languages:
			nut.importRegion(region, language, save=False)
			Titles.save('titledb/titles.%s.%s.json' % (region, language), False)
			#Print.info('%s - %s' % (region, language))
	nut.importRegion()
	exit(0)
示例#6
0
def updateTitleDb(force=False):
    if not Config.autoUpdateTitleDb and not force:
        return

    try:
        os.mkdir('titledb')
    except BaseException:
        pass

    Print.info('downloading titledb files')

    try:
        with open('titledb/db.bin', 'wb') as f:
            bytes = download('http://tinfoil.media/repo/db/db.bin',
                             f,
                             checkSize=False)

        decompressZstd('titledb/db.bin', 'titledb/db.nza')
        container = Fs.Nsp('titledb/db.nza')

        container.open('titledb/db.nza', 'rb')
        for nspf in container:
            with open(os.path.join('titledb', nspf._path), 'wb') as f:
                while not nspf.eof():
                    f.write(nspf.read(8 * 1000 * 1000))

        container.close()

        try:
            os.remove('titledb/db.nza')
        except BaseException:
            pass

        refreshRegions(save=False)
        importRegion(Config.region, Config.language)
        return

    except BaseException as e:
        Print.error('error getting tinfoil.io titledb: ' + str(e))

    fileList = []

    for region, languages in Config.regionLanguages().items():
        for language in languages:
            fileList.append('%s.%s.json' % (region.upper(), language.lower()))

    for path in fileList:
        downloadRepoFile(path)

    refreshRegions(save=False)
    importRegion(Config.region, Config.language)
示例#7
0
def scrapeShogunUnnamed():
    initTitles()
    initFiles()

    result = {}

    for k, t in Titles.data().items():
        if not t.isDLC:
            continue

        if not t.name and t.baseId != '0100069000078000':
            result[t.baseId] = True

    if not Config.dryRun:
        for id, j in tqdm(result.items()):
            try:
                for region, languages in Config.regionLanguages().items():
                    for language in languages:
                        t = Titles.getTitleId(id, region, language)

                        if t:
                            s = cdn.Shogun.scrapeTitle(int(t.nsuId),
                                                       region=region,
                                                       language=language,
                                                       force=False)
                            #print(json.dumps(s.__dict__))
            except:
                pass

        for region, languages in Config.regionLanguages().items():
            for language in languages:
                Titles.saveRegion(region, language)

        Titles.save()
    else:
        print(result)
示例#8
0
    def __init__(self):
        super(QWidget, self).__init__()

        layout = QGridLayout(self)

        regions = []
        for region, languages in Config.regionLanguages().items():
            regions.append(region)

        regions.sort()

        width = 4
        i = 0
        for region in regions:
            layout.addWidget(RegionEntry(region), i // width, i % width)
            i += 1
示例#9
0
文件: nut.py 项目: blawar/nut
                    nut.initFiles()
                    for d in args.download:
                        download(d)

                if args.system_update:
                    cdn.downloadSystemUpdate()

                if args.scrape_shogun is not None:
                    if len(args.scrape_shogun) == 0:
                        nut.scrapeShogunThreaded(True)
                    else:
                        nut.initTitles()
                        nut.initFiles()
                        for i in args.scrape_shogun:
                            if len(i) == 16:
                                for region in Config.regionLanguages():
                                    if args.region and region != args.region:
                                        continue

                                    for language in Config.regionLanguages(
                                    )[region]:
                                        if args.language and args.language != language:
                                            continue

                                        l = cdn.Shogun.ids(i,
                                                           region=region,
                                                           language=language
                                                           or 'en',
                                                           force=True)
                                        print('searching %s %s' %
                                              (region, language))
示例#10
0
def getRegions(request, response):
    response.write(json.dumps(Config.regionLanguages()))
示例#11
0
 def test_regional_languages_from_file(self):
     file_ = 'titledb/languages.json'
     languages = '{"CO":["en","es"],"AR":["en","es"],"CL":["en","es"]}'
     self.fs.create_file(file_, contents=languages)
     self.assertEqual(Config.regionLanguages(), json.loads(languages))
示例#12
0
 def test_region_languages_with_empty_file(self):
     self.assertEqual(Config.regionLanguages(), _get_default_languages())
     # return same object
     self.assertEqual(Config.regionLanguages(), _get_default_languages())
示例#13
0
def getRegions(request, response):
    response.headers['Content-Type'] = 'application/json'
    response.write(json.dumps(Config.regionLanguages()))