예제 #1
0
async def main():
	nas = nnas.NNASClient()
	nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
	nas.set_title(MK8.TITLE_ID_EUR, MK8.LATEST_VERSION)
	nas.set_locale(REGION_ID, COUNTRY_NAME, LANGUAGE)
	
	access_token = await nas.login(USERNAME, PASSWORD)
	nex_token = await nas.get_nex_token(access_token.token, MK8.GAME_SERVER_ID)
	
	s = settings.default()
	s.configure(MK8.ACCESS_KEY, MK8.NEX_VERSION)
	async with backend.connect(s, nex_token.host, nex_token.port) as be:
		async with be.login(str(nex_token.pid), nex_token.password) as client:
			ranking_client = ranking.RankingClient(client)
	
			order_param = ranking.RankingOrderParam()
			order_param.order_calc = ranking.RankingOrderCalc.ORDINAL
			order_param.offset = 499 #Start at 500th place
			order_param.count = 20 #Download 20 highscores
	
			rankings = await ranking_client.get_ranking(
				ranking.RankingMode.GLOBAL, TRACK_ID,
				order_param, 0, 0
			)
	
			ranking_stats = await ranking_client.get_stats(
				TRACK_ID, order_param, ranking.RankingStatFlags.ALL
			)
		
			names = await nas.get_nnids([data.pid for data in rankings.data])
	
			#Print some interesting stats
			stats = ranking_stats.stats
			print("Total:", int(stats[0]))
			print("Total time:", format_time(stats[1]))
			print("Lowest time:", format_time(stats[2]))
			print("Highest time:", format_time(stats[3]))
			print("Average time:", format_time(stats[4]))
	
			print("Rankings:")
			for rankdata in rankings.data:
				time = format_time(rankdata.score)
				print("\t%5i   %20s   %s" %(rankdata.rank, names[rankdata.pid], time))
		
			#Let's download the replay file of whoever is in 500th place
			store = datastore.DataStoreClient(client)
			
			rankdata = rankings.data[0]
			get_param = datastore.DataStorePrepareGetParam()
			get_param.persistence_target.owner_id = rankdata.pid
			get_param.persistence_target.persistence_id = TRACK_ID - 16
			get_param.extra_data = ["WUP", str(REGION_ID), REGION_NAME, str(COUNTRY_ID), COUNTRY_NAME, ""]
			
			req_info = await store.prepare_get_object(get_param)
			headers = {header.key: header.value for header in req_info.headers}
			response = await http.get(req_info.url, headers=headers)
			response.raise_if_error()
			
			with open("replay.bin", "wb") as f:
				f.write(response.body)
예제 #2
0
async def main():
    nas = nnas.NNASClient()
    nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
    nas.set_title(DKCTF.TITLE_ID_EUR, DKCTF.LATEST_VERSION)
    nas.set_locale(REGION, COUNTRY, LANGUAGE)

    access_token = await nas.login(USERNAME, PASSWORD)
    nex_token = await nas.get_nex_token(access_token.token,
                                        DKCTF.GAME_SERVER_ID)

    s = settings.default()
    s.configure(DKCTF.ACCESS_KEY, DKCTF.NEX_VERSION)
    async with backend.connect(s, nex_token.host, nex_token.port) as be:
        async with be.login(str(nex_token.pid), nex_token.password) as client:
            order_param = ranking.RankingOrderParam()
            order_param.offset = 0  #Start with the world record
            order_param.count = 20  #Download 20 highscores

            ranking_client = ranking.RankingClient(client)
            rankings = await ranking_client.get_ranking(
                ranking.RankingMode.GLOBAL,  #Get the global leaderboard
                0x893EB726,  #Category, this is 3-A (Magrove Cove)
                order_param,
                0,
                0)

            print("Total:", rankings.total)
            print("Rankings:")
            for rankdata in rankings.data:
                seconds = (rankdata.score >> 1) / 60
                time = "%i:%02i.%02i" % (seconds / 60, seconds % 60,
                                         (seconds * 100) % 100)
                damage = " Damaged " if rankdata.score & 1 else "No damage"
                kong = ["No Kong", "Diddy", "Dixie",
                        "Cranky"][rankdata.groups[1]]
                name = rankdata.common_data.decode("ascii")[:-1]

                print("\t%2i   %20s   %s (%s)   %s" %
                      (rankdata.rank, name, time, damage, kong))

            #Now download the world record replay file if available
            world_record = rankings.data[0]
            if world_record.param:  #If world record has a replay file
                store = datastore.DataStoreClient(client)

                get_param = datastore.DataStorePrepareGetParam()
                get_param.data_id = world_record.param

                req_info = await store.prepare_get_object(get_param)
                headers = {
                    header.key: header.value
                    for header in req_info.headers
                }
                response = await http.get(req_info.url, headers=headers)
                response.raise_if_error()

                with open("replay.bin", "wb") as f:
                    f.write(response.body)
예제 #3
0
async def nas_login():
    global nex_token

    nas = nnas.NNASClient()
    nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
    nas.set_title(SMM.TITLE_ID_EUR, SMM.LATEST_VERSION)
    nas.set_locale(REGION_ID, COUNTRY_NAME, LANGUAGE)

    access_token = await nas.login(USERNAME, PASSWORD)
    nex_token = await nas.get_nex_token(access_token.token, SMM.GAME_SERVER_ID)
예제 #4
0
                print(title_id + " / " + title_name)
                RPC.update(state=title_name,
                           start=start_time,
                           small_image="nn",
                           small_text=MAINID,
                           large_image=title_id.lower())

        else:
            print("Unknown notification type %i (from %s)" %
                  (event.type, name))

    def process_presence_change_event(self, context, event):
        self.process_nintendo_notification_event(context, event)


nnas = nnas.NNASClient()
nnas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
nnas.set_locale(REGION, COUNTRY, LANGUAGE)
nnas.set_title(Friends.TITLE_ID_EUR, Friends.LATEST_VERSION)
nnas.login(USERNAME, PASSWORD)

nex_token = nnas.get_nex_token(Friends.GAME_SERVER_ID)
backend = backend.BackEndClient("friends.cfg")
backend.configure(Friends.ACCESS_KEY, Friends.NEX_VERSION)
backend.connect(nex_token.host, nex_token.port)

login_data = authentication.NintendoLoginData()
login_data.token = nex_token.token
backend.login(nex_token.username, nex_token.password, None, login_data)
backend.secure_client.register_server(NotificationServer())
예제 #5
0
async def main():
    nas = nnas.NNASClient()
    nas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION)
    nas.set_title(Friends.TITLE_ID_EUR, Friends.LATEST_VERSION)
    nas.set_locale(REGION, COUNTRY, LANGUAGE)

    access_token = await nas.login(USERNAME, PASSWORD)
    nex_token = await nas.get_nex_token(access_token.token,
                                        Friends.GAME_SERVER_ID)

    pid = await nas.get_pid(USERNAME)
    mii = await nas.get_mii(pid)

    s = settings.load("friends")
    s.configure(Friends.ACCESS_KEY, Friends.NEX_VERSION)
    async with backend.connect(s, nex_token.host, nex_token.port) as be:
        async with be.login(str(nex_token.pid), nex_token.password) as client:
            nna_info = friends.NNAInfo()
            nna_info.principal_info.pid = pid
            nna_info.principal_info.nnid = USERNAME
            nna_info.principal_info.mii.name = mii.name
            nna_info.principal_info.mii.data = mii.data

            #NintendoPresenceV2 tells the server about your online status, which
            #game you're currently playing, etc. This will be shown to your friends
            #in their friend list (unless you disabled this feature).
            presence = friends.NintendoPresenceV2()

            friends_client = friends.FriendsClientV2(client)
            response = await friends_client.update_and_get_all_information(
                nna_info, presence, BIRTHDAY)

            if response.comment.text:
                print("Your status message: %s (last changed on %s)" %
                      (response.comment.text, response.comment.changed))
            else:
                print("You don't have a status message")

            if response.friends:
                print("Friends:")
                for friend in response.friends:
                    principal_info = friend.nna_info.principal_info
                    print("\tNNID:", principal_info.nnid)
                    print("\tName:", principal_info.mii.name)

                    presence = friend.presence
                    print("\tOnline:", ["No", "Yes"][presence.is_online])
                    if presence.game_key.title_id:
                        print("\tPlaying: %016X (v%i)" %
                              (presence.game_key.title_id,
                               presence.game_key.title_version))

                    if friend.comment.text:
                        print("\tStatus: %s (last changed on %s)" %
                              (friend.comment.text, friend.comment.changed))

                    print("\tFriend since:", friend.befriended)
                    print("\tLast online:", friend.last_online)
                    print("\t" + "-" * 40)
                print()
            else:
                print("You don't have any friends")

            if response.sent_requests:
                print("Friend requests sent:")
                print_requests(response.sent_requests)
            else:
                print("You haven't sent any friend requests")

            if response.received_requests:
                print("Friend requests received:")
                print_requests(response.received_requests)
            else:
                print("You haven't received any friend requests")

            if response.blacklist:
                print("Blacklist:")
                for item in response.blacklist:
                    principal_info = item.principal_info
                    print("\tWho: %s (%s)" %
                          (principal_info.nnid, principal_info.mii.name))
                    if item.game_key.title_id:
                        print("\tGame: %016X (%i)" %
                              (item.game_key.title_id,
                               item.game_key.title_version))
                    print("\tSince:", item.since)
                    print("\t" + "-" * 40)
            else:
                print("You haven't blacklisted any users")
예제 #6
0
async def main():
	nas = nnas.NNASClient()
	pid = await nas.get_pid("Kinnay-WiiU")
	mii = await nas.get_mii(pid)
	print("NNID:", mii.nnid)
	print("PID:", mii.pid)
	print("Name:", mii.name)

	info = miis.MiiData.parse(mii.data)
	print("Mii:")
	print("\tBirthday: %i-%i" %(info.birth_day, info.birth_month))
	print("\tCreator name:", info.creator_name)
	print("\tMii color:", info.color)
	print("\tMii size: %i%%" %(info.size / 128 * 100))
	print("\tMii weight: %i%%" %(info.fatness / 128 * 100))
	print("\tGender:", ["Male", "Female"][info.gender])
	print("\t----------")
	print("\tBlush style:", info.blush_type)
	print("\tFace style:", info.face_style)
	print("\tFace color:", info.face_color)
	print("\tFace shape:", info.face_type)
	print("\t----------")
	print("\tHair style:", info.hair_type)
	print("\tHair color:", info.hair_color)
	print("\tHair mirrored:", ["No", "Yes"][info.hair_mirrored])
	print("\t----------")
	print("\tEye style:", info.eye_type)
	print("\tEye color:", info.eye_color)
	print("\tEye size:", info.eye_scale)
	print("\tEye thickness:", info.eye_thickness)
	print("\tEye height:", info.eye_height)
	print("\tEye distance:", info.eye_distance)
	print("\tEye rotation:", info.eye_rotation)
	print("\t----------")
	print("\tEyebrow style:", info.eyebrow_type)
	print("\tEyebrow color:", info.eyebrow_color)
	print("\tEyebrow size:", info.eyebrow_scale)
	print("\tEyebrow thickness:", info.eyebrow_thickness)
	print("\tEyebrow height:", info.eyebrow_height)
	print("\tEyebrow distance:", info.eyebrow_distance)
	print("\tEyebrow rotation:", info.eyebrow_rotation)
	print("\t----------")
	print("\tNose style:", info.nose_type)
	print("\tNose size:", info.nose_scale)
	print("\tNose height:", info.nose_height)
	print("\t----------")
	print("\tMouth style:", info.mouth_type)
	print("\tMouth color:", info.mouth_color)
	print("\tMouth size:", info.mouth_scale)
	print("\tMouth thickness:", info.mouth_thickness)
	print("\tMouth height:", info.mouth_height)
	print("\t----------")
	print("\tMustache style:", info.mustache_type)
	if info.mustache_type:
		print("\tMustache height:", info.mustache_height)
		print("\tMustache size:", info.mustache_scale)
	print("\tBeard style:", info.beard_type)
	if info.beard_type:
		print("\tBeard color:", info.beard_color)
	print("\t----------")
	print("\tGlasses style:", info.glass_type)
	if info.glass_type:
		print("\tGlasses color:", info.glass_color)
		print("\tGlasses size:", info.glass_scale)
		print("\tGlasses height:", info.glass_height)
	print("\t----------")
	print("\tMole:", ["No", "Yes"][info.mole_enabled])
	if info.mole_enabled:
		print("\tMole size:", info.mole_scale)
		print("\tMole X:", info.mole_xpos)
		print("\tMole Y:", info.mole_ypos)

	print("Images:")
	for image in mii.images:
		print("\t%s" %image.url)