├── .gitignore ├── LICENSE ├── README.md ├── USAGE.md ├── changelog.md ├── docs └── index.md ├── examples ├── areFriendsUuid.py ├── serverLikeNumber.py ├── verifyLikeUsername.py └── verifyLikeUuid.py ├── install ├── install.bat └── install.txt ├── namemcpy ├── __init__.py └── namemc.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # disable vscode config folder tracking 2 | .vscode 3 | 4 | # disable env tracking 5 | env -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Lasscat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![PyPI version](https://badge.fury.io/py/namemcpy.svg)[![PyPI license](https://img.shields.io/pypi/l/namemcpy.svg) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 2 | # About📄 3 | namemcpy is a api wrapper for [NameMC](https://namemc.com). 4 | Some features of this library scrape the website and will potentially break if the website changes. 5 | 6 | 7 | Please note the author of namemcpy & namemcpy is not affiliated with [namemc](https://namemc.com/) in any way. 8 | 9 | 10 | # How to install 💾 11 | 12 | `pip install namemcpy` 13 | 14 | `pip3 install namemcpy` 15 | 16 | `pip3 install -r install.txt` 17 | 18 | Or just run the .bat file in the install folder. 19 | 20 | # Usage (WIP) ✏️ 21 | 22 | For usage check out the [Wiki](https://github.com/lasscat/namemcpy/wiki) (Recommended.) or, alternativly check out the [usage.md](https://github.com/lasscat/namemcpy/blob/main/USAGE.md) (Not recommended as it's highly outdated.) 23 | 24 | # Credits ❤️ 25 | Anyone who contributes gets added. If I have not added you please DM me on discord (lasscat#7377). To all the contributors thank you so much for your support, I would not be here without all of you. ❤️ Thanks for the stars. 26 | 27 | [lasscat](https://github.com/lasscat) 28 | 29 | [BluCobalt](https://github.com/BluCobalt) 30 | 31 | [DarkOnion0](https://github.com/DarkOnion0) 32 | 33 | [Eslam513](https://github.com/Eslam512) 34 | 35 | [Atteure](https://github.com/atteure) 36 | 37 | 38 | # TODO 🧠 39 | Get server ping with getPing() 40 | 41 | Make a Read the Docs page 42 | 43 | Update examples 44 | 45 | Fix the problem with not showing all skins because of the page showing just a couple use the dedicated url to get all skins. 46 | 47 | Add a terminal cmd kind of think like swiss7 48 | 49 | add get ping 50 | -------------------------------------------------------------------------------- /USAGE.md: -------------------------------------------------------------------------------- 1 | # Usage✏️ 2 | 3 | ## def printFriendList(self, playerInput=False, uuidInput=False, output=False): 4 | Prints frined list if you are searching by a player fill outt the playerinput to username same thing for uuid but with uuids, and output will be uuid or player which will print or return the uuids or usernames of the targets friend list, 5 | 6 | ## def areFriends(self, uuid1=False, uuid2=False, username1=False, username2=False): 7 | Sees if you are friends with another player. uuid1 is the friends list you will be searching and uuid2 is the friend you will be looking for. vice versa for username 8 | if you want to search by usernames enter the values for usernames and vice versa for uuids. 9 | 10 | ## serverLikeNumber(server) 11 | Enter the servers domain name (ex: example.com). It will return the number of people are liking the server on namemc. 12 | 13 | ## def verifyLike(self, server, uuid=False, username=False): 14 | Enter server and for if you are verifying a like by uuid enter uuid and for username enter username when calling function 15 | 16 | ## uuidToUsername(uuid) 17 | (THIS IS NOT A PART OF NAMEMC API JUST SOME FEATURE THAT I THOUGHT MIGHT BE USEFULL FOR ALL OF YOU. YOU CAN ALSO YOU THE BUILT IN FUNCTIONS THAT AUTO CONVERT IT ALSO.) 18 | Uuid to Username (returns username) 19 | 20 | ## usernameToUuid(username) 21 | (THIS IS NOT A PART OF NAMEMC API JUST SOME FEATURE THAT I THOUGHT MIGHT BE USEFULL FOR ALL OF YOU YOU CAN ALSO YOU THE BUILT IN FUNCTIONS THAT AUTO CONVERT IT ALSO.) 22 | username to uuid (returns uuid) 23 | 24 | ## skinUsers(skinid) 25 | (this feature does not use namemcapi It scrapes the website for skin users may not be 100% accurate but Im 90% sure it is.) 26 | Enter the skin id to the skin you want to get the users from and it will return a value for all the names/players who are wearing the skin. 27 | 28 | ## getSkinTags(skinid) 29 | (this feature does not use namemcapi It scrapes the website for skin users may not be 100% accurate but Im 90% sure it is.) 30 | Get the skin tags or hashtags on a skin 31 | 32 | ## getSkinNumber(skinid) 33 | (this feature does not use namemcapi It scrapes the website for skin users may not be 100% accurate but Im 90% sure it is.) 34 | Get how much people are using a skin 35 | 36 | ##def playerSkins(self, current=False, username=False, uuid=False): 37 | (this feature does not use namemcapi It scrapes the website for skin users may not be 100% accurate but Im 90% sure it is.) 38 | Playername to player skin history (outputted in hashes) 39 | 40 | ##def renderSkin(self, skinhash, model, x=False, y=False, directon=False, time=False): 41 | Rende skins. 42 | 43 | 44 | For more detail check out the examples folder. (not updated very often) 45 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # 1.5.0 4-3-2021 2 | Added a new feature when you can see if your name drops thanks eslam512 3 | 4 | # 1.4.3 2-28-2021 5 | Hi everyone, thsi update we fixed this issue https://github.com/lasscat/namemcpy/issues/6 6 | 7 | # v1.4.2 2-26-2021 8 | Happy valentines day, this update we fixed a bug with capeusernumber again. 9 | 10 | # v1.4.1 1-27-2021 11 | Happy new year, this update we fixed a bug with capeusernumber. 12 | 13 | # v1.4.0 12-14-2020🥳 14 | Added 2 new functions renderskin, and playerskin 15 | 16 | # v1.3.4 12-14-2020🎉 17 | Fixed some things that my trigger your OCD. 18 | # v1.3.3 11-27-2020🎉 19 | Fixed spacing errors that caused the program to break. 20 | 21 | # v1.3.0 11-27-2020🥳 22 | Accidentally left some stuff that I dont need and forgot to update the version function. 23 | 24 | # v1.3.0 11-27-2020🥳 25 | Shortened many functions to make them easier to use and reduce lines of code when updating to this version please change your code as it will break. 26 | 27 | # v1.2.0🎉 28 | Bigger update adding soem namemc non api features such as getskinnumber() getskintags() skinusers() and added some more comments to make reading or understanding some stuff easier. 29 | 30 | # v1.1.1 11-18-2020🎉 31 | 32 | Smaller update just got rid of a scraped function that I accidently left in the code. 33 | 34 | # v1.1.0 11-18-2020🥳 35 | 36 | 1. Added it so when you call a function it will return a value instead of print some useless stuff (if you still want this feature just do a if statment if true or false print(stuff) 37 | 38 | 2. Added 2 new function uuidToUsername() and usernameToUuid() pretty self explanatory. 39 | 40 | 3. Fixed some typos and the printFriendListUsernameOutputUuid() As it would outputing name, which was fixed. 41 | 42 | Pretty much it. 43 | 44 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Usage✏️ 2 | 3 | ## def printFriendList(self, playerInput=False, uuidInput=False, output=False): 4 | Prints frined list if you are searching by a player fill outt the playerinput to username same thing for uuid but with uuids, and output will be uuid or player which will print or return the uuids or usernames of the targets friend list, 5 | 6 | ## def areFriends(self, uuid1=False, uuid2=False, username1=False, username2=False): 7 | Sees if you are friends with another player. uuid1 is the friends list you will be searching and uuid2 is the friend you will be looking for. vice versa for username 8 | if you want to search by usernames enter the values for usernames and vice versa for uuids. 9 | 10 | ## serverLikeNumber(server) 11 | Enter the servers domain name (ex: example.com). It will return the number of people are liking the server on namemc. 12 | 13 | ## def verifyLike(self, server, uuid=False, username=False): 14 | Enter server and for if you are verifying a like by uuid enter uuid and for username enter username when calling function 15 | 16 | ## uuidToUsername(uuid) 17 | (THIS IS NOT A PART OF NAMEMC API JUST SOME FEATURE THAT I THOUGHT MIGHT BE USEFULL FOR ALL OF YOU. YOU CAN ALSO YOU THE BUILT IN FUNCTIONS THAT AUTO CONVERT IT ALSO.) 18 | Uuid to Username (returns username) 19 | 20 | ## usernameToUuid(username) 21 | (THIS IS NOT A PART OF NAMEMC API JUST SOME FEATURE THAT I THOUGHT MIGHT BE USEFULL FOR ALL OF YOU YOU CAN ALSO YOU THE BUILT IN FUNCTIONS THAT AUTO CONVERT IT ALSO.) 22 | username to uuid (returns uuid) 23 | 24 | ## skinUsers(skinid) 25 | (this feature does not use namemcapi It scrapes the website for skin users may not be 100% accurtae but Im 90% sure it is.) 26 | Enter the skin id to the skin you want to get the users from and it will return a value for all the names/players who are wearing the skin. 27 | 28 | ## getSkinTags(skinid) 29 | (this feature does not use namemcapi It scrapes the website for skin users may not be 100% accurtae but Im 90% sure it is.) 30 | Get the skin tags or hashtags on a skin 31 | 32 | ## getSkinNumber(skinid) 33 | (this feature does not use namemcapi It scrapes the website for skin users may not be 100% accurtae but Im 90% sure it is.) 34 | Get how much people are using a skin 35 | 36 | 37 | For more detail check out the examples folder. (not updated very often) 38 | -------------------------------------------------------------------------------- /examples/areFriendsUuid.py: -------------------------------------------------------------------------------- 1 | from namemcpy import namepy 2 | example = namepy() 3 | test = example.areFriendsUuid(uuid1='49a7bf33772045bc9f75712d15cdf544', uuid2='10fad8a9efe44713bf118ccc384de574') 4 | print(test) 5 | 6 | #output returns true or fals 7 | -------------------------------------------------------------------------------- /examples/serverLikeNumber.py: -------------------------------------------------------------------------------- 1 | from namemcpy import namepy 2 | example = namepy() 3 | test = example.serverLikeNumber(server='example.com') 4 | print(test) 5 | 6 | #output 7 | #the server has number of likes 8 | # 9 | # 10 | -------------------------------------------------------------------------------- /examples/verifyLikeUsername.py: -------------------------------------------------------------------------------- 1 | from namemcpy import namepy 2 | example = namepy() 3 | test = example.verifyLikeUsername(server='example.com', username='example') 4 | print(test) 5 | 6 | # OUTPUT 7 | #if username is not liking the server then 8 | #print(the username (username) is not liking the server (server)) 9 | #returns false 10 | #if username is liking the server then 11 | #print(the username (username) is liking the server (server)) 12 | #return true 13 | -------------------------------------------------------------------------------- /examples/verifyLikeUuid.py: -------------------------------------------------------------------------------- 1 | from namemcpy import namepy 2 | example = namepy() 3 | test = example.verifyLikeUuid(server='example.com', uuid='uuid') 4 | print(test) 5 | 6 | # OUTPUT 7 | #if uuid is not liking the server then 8 | #print(the uuid (uuid) is not liking the server (server)) 9 | return False 10 | #if uuid is liking the server then 11 | #print(the uuid (uuid) is liking the server (server)) 12 | return True 13 | -------------------------------------------------------------------------------- /install/install.bat: -------------------------------------------------------------------------------- 1 | pip install namemcpy 2 | -------------------------------------------------------------------------------- /install/install.txt: -------------------------------------------------------------------------------- 1 | namemcpy 2 | -------------------------------------------------------------------------------- /namemcpy/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /namemcpy/namemc.py: -------------------------------------------------------------------------------- 1 | """ 2 | MIT License 3 | 4 | Copyright (c) 2020 Lasscat 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | """ 24 | 25 | import time 26 | import requests 27 | import json 28 | from bs4 import BeautifulSoup 29 | ts = time.time() 30 | import datetime 31 | from datetime import datetime, timezone 32 | class namepy(): 33 | 34 | def __init__(self): 35 | """pretty much every variable for links for api ect""" 36 | self.url = 'https://namemc.com' 37 | self.api_url = 'https://api.mojang.com/users/profiles/minecraft/' 38 | self.friend_url = 'https://api.namemc.com/profile/' 39 | self.like_list = 'https://api.namemc.com/server/' # + /likes 40 | self.uuid_api_url = 'https://sessionserver.mojang.com/session/minecraft/profile/' 41 | self.skin_url = 'https://namemc.com/skin/' 42 | self.cape_url = 'https://namemc.com/cape/' 43 | self.user_profile_url = 'https://namemc.com/profile/' 44 | self.drop = 'https://api.kqzz.me/api/namemc/droptime/' 45 | 46 | def __version__(self): 47 | """returns version number""" 48 | return "1.4.1" # returns namepy version 49 | 50 | def printFriendList(self, playerInput=False, uuidInput=False, output=False): # add a function to find a users friend my username (player) is the player you want to search the friends of 51 | "print friends list search by username and the ouput being username" 52 | if isinstance(playerInput, str): # if playerinput is a bool or a string then 53 | if output == 'username' or output == 'player' or output == 'uuid': # just to make sure that the player entered or spelled the output thing right 54 | friend_list = [] 55 | 56 | r = requests.get(self.api_url + playerInput + '?at=' + str(ts)).json() # uses mojangs api scrapes website (there uuid is the "id" part) (ts is the timestamp in unix) 57 | 58 | uuid = (r['id']) # gets uuid 59 | 60 | friend_scrape = requests.get(self.friend_url + str(uuid) + '/friends').json() # scrapes the url we just made # ^\ 61 | 62 | for players in friend_scrape: 63 | if output == 'uuid': 64 | friend_list.append(players['uuid']) # if output or player said uuid just prints all uuids and appends to list 65 | if output == 'username' or output == 'player': 66 | friend_list.append(players['name']) # if player said output username appends list 67 | return friend_list 68 | 69 | if isinstance(uuidInput, str): 70 | if output == 'username' or output == 'player' or output == 'uuid': 71 | friend_scrape = requests.get(self.friend_url + str(uuidInput) + '/friends').json() # scrapes the url we just made # ^\ 72 | 73 | for players in friend_scrape: 74 | if output == 'uuid': 75 | friend_list.append(players['uuid']) # if output or player said uuid just prints all uuids and appends to list 76 | if output == 'username' or output == 'player': 77 | friend_list.append(players['name']) # if player said output username appends list 78 | return friend_list 79 | 80 | def areFriends(self, uuid1=False, uuid2=False, username1=False, username2=False): # player1 is the user you will be searching the friends list and player 2 is the player you will look in player1's friend list 81 | """find if a user is friends by username""" 82 | 83 | friend_list = [] 84 | 85 | if isinstance(username1, str) and isinstance(username2, str): 86 | # -------getting player 1 uuid------- 87 | player_1_link = requests.get(self.api_url + username1 + "?at=" + str(ts)).json() # look at printfriendlist for what this means 88 | player_1_uuid = (player_1_link['id']) # gets player 1 uuid value and stores it into the var 89 | # ------------------- 90 | response_namemc = requests.get(self.friend_url + player_1_uuid + '/friends').json() 91 | 92 | if isinstance(uuid1, str) and isinstance(uuid2, str): 93 | response_namemc = requests.get(self.friend_url + uuid1 + '/friends').json() 94 | 95 | for friends in response_namemc: 96 | 97 | if isinstance(uuid1, str) and isinstance(uuid2, str): 98 | friend_list.append(friends['uuid']) 99 | 100 | if isinstance(username1, str) and isinstance(username2, str): 101 | friend_list.append(friends['name']) 102 | 103 | if isinstance(uuid1, str) and (uuid2, str): 104 | print(friend_list) 105 | if uuid2 in friend_list: # if player2 is in friends list 106 | return True 107 | 108 | if uuid2 not in friend_list: # if player2 is not in friends list 109 | return False 110 | 111 | if isinstance(username1, str) and isinstance(username2, str): 112 | 113 | if username2 in friend_list: # if player2 is in friends list 114 | return True 115 | 116 | if username2 not in friend_list: # if player2 is not in friends list 117 | return False 118 | 119 | 120 | def serverLikeNumber(self, server): #server list being the servers ip INCLUDE THE DOMAIN TLD 121 | """get the server like number""" 122 | 123 | likes = [] # creates a list so we can append all the likes to this list later 124 | server_api_url = self.like_list + server + '/likes' 125 | server_url_request = requests.get(server_api_url).json() #requests get the url from above ^ then jsons it 126 | 127 | 128 | for players in server_url_request: 129 | likes.append(players) 130 | #prints output of uuids 131 | 132 | len_likes = int(len(likes)) # len likes the list to make it a number then int it so it can be a interger 133 | return len_likes 134 | 135 | def verifyLike(self, server, uuid=False, username=False): 136 | """verify like by username""" 137 | 138 | if isinstance(username, str): 139 | # -------getting username to uuid------- 140 | username_2_uuid_request = requests.get(self.api_url + username + '?at=' + str(ts)).json() 141 | player2uuid = (username_2_uuid_request['id']) 142 | 143 | namemc_verify_like_url = self.like_list + server + '/likes?profile=' + str(player2uuid) 144 | namemc_verify_like_url_request = requests.get(namemc_verify_like_url).json() # will give a output of true or false true being is liking the server and false being the player is not liking the server 145 | 146 | if isinstance(uuid, str): 147 | namemc_verify_like_url = self.like_list + server + '/likes?profile=' + str(input) 148 | 149 | namemc_verify_like_url_request = requests.get(namemc_verify_like_url).json() # will give a output of true or false true being is liking the server and false being the player is not liking the server 150 | # namemc api 151 | if namemc_verify_like_url_request == False: 152 | return False 153 | if namemc_verify_like_url_request == True: 154 | return True 155 | # if namemc_verify)_like_url output is false or true give response ect 156 | 157 | def usernameToUuid(self, username): 158 | """username to uuid""" 159 | 160 | # -------getting username to uuid------- 161 | username_2_uuid_url = requests.get(self.api_url + username + '?at=' + str(ts)).json() 162 | username_2_uuid = (username_2_uuid_url['id']) 163 | # ------------------- 164 | return username_2_uuid 165 | 166 | def uuidToUsername(self, uuid): 167 | 168 | # -------getting uuid to username------- 169 | username_2_uuid_url = requests.get(self.uuid_api_url + uuid).json() 170 | username_2_uuid = (username_2_uuid_url['name']) 171 | # ------------------- 172 | return username_2_uuid 173 | 174 | def skinUsers(self, skinid): # some test package not using namemcs api we have to scrape 175 | """Find all users with the skinid you entered.""" 176 | 177 | skin_users_list = [] 178 | 179 | skin_link = requests.get(self.skin_url + skinid)# scrapes link then requests get it 180 | 181 | soup = BeautifulSoup(skin_link.content, 'html.parser') #beatuiful soups the request var we made then html parse it (var holds are the data from the website) 182 | 183 | """"extracing info (via class)""" 184 | username_box_result = soup.find_all('div', class_='card-body player-list py-2') # find everything under div and the class for the usernames are stored 185 | 186 | for results in username_box_result: # for things in usernameboxreslt 187 | for usernames in results.find_all('a', href=True): # this just sorts everything to href libary which we need to search the naems in 188 | skin_users_list.append(usernames.text) # adds all names to list 189 | 190 | if ValueError: # if no one using skin returns false 191 | return False # false meaning no one is using the skin 192 | 193 | else: #if no error do this 194 | 195 | skin_users_list.remove('…') # removes something that is not a name 196 | 197 | return skin_users_list # returns 198 | 199 | def getSkinTags(self, skinid): 200 | """gets skin tags on namemc""" 201 | empty_tags = [] # for refrence at end 202 | tags = [] # list we will be storing the tags in 203 | 204 | skin_link = requests.get(self.skin_url + skinid) # get link 205 | soup = BeautifulSoup(skin_link.content, 'html.parser') #parses html 206 | 207 | tag_box_result = soup.find_all('div', class_='card-body text-center py-1') # stripen down list 208 | 209 | for tag in tag_box_result: 210 | for each_tag in tag.find_all(href=True): #stripen down list to just tags 211 | tags.append(each_tag.text) 212 | 213 | return tags 214 | 215 | if tags == empty_tags: 216 | return False #returns false if there are no tags 217 | 218 | def getSkinNumber(self, skinid): 219 | """ gets how many users are wearing a certain skin """ 220 | 221 | user_list = [] 222 | 223 | skin_link = requests.get(self.skin_url + skinid) 224 | soup = BeautifulSoup(skin_link.content, 'html.parser') 225 | 226 | username_box_result = soup.find_all('div', class_='card-body player-list py-2') # find everything under div and the class for the usernames are stored 227 | for results in username_box_result: # for things in usernameboxreslt 228 | for usernames in results.find_all('a', href=True): # this just sorts everything to href libary which we need to search the naems in 229 | user_list.append(usernames.text) # adds all names to list 230 | number = len(user_list) # lens the list for all users 231 | 232 | 233 | return number #returns the number value 234 | 235 | def getCapeUsers(self, capeid): 236 | 237 | cape_user_list = [] 238 | 239 | cape_request = requests.get(self.cape_url + capeid) 240 | 241 | soup = BeautifulSoup(cape_request.text, 'html.parser') 242 | cape_scrape = soup.find_all('div', class_='card-body player-list py-2') 243 | 244 | for capeusers in cape_scrape: 245 | for get_cape in capeusers.find_all('a', href=True): 246 | cape_user_list.append(get_cape.text) 247 | 248 | return cape_user_list 249 | 250 | def capeUserNumber(self, capehash): 251 | 252 | test_var = 0 253 | 254 | cape_request = requests.get(self.cape_url + capehash) 255 | 256 | soup = BeautifulSoup(cape_request.text, 'html.parser') 257 | cape_scrape = soup.find_all('div', class_='card-body player-list py-2') 258 | 259 | for cape_user in cape_scrape: 260 | for capeNumber in cape_user.find_all('a', href=True): 261 | test_var +=1 262 | 263 | if test_var > 3000 or capehash == '1981aad373fa9754' or capehash == '72ee2cfcefbfc081' or capehash == '0e4cc75a5f8a886d' or capehash == 'ebc798c3f7eca2a3' or capehash == '9349fa25c64ae935': # reason why i have if greatrer than 3000 is for the account migration stuff and how much people are going to have it so i dont have to update this the day migration comes out 264 | return test_var - 1 265 | else: 266 | return test_var 267 | 268 | 269 | def playerSkins(self, current=False, username=False, uuid=False): #username or uuid is 'false' because its not mandatory to enter them11 270 | 271 | skin_hash_list = [] #makes list to store all skin hashes that namemc is using 272 | final_list = [] 273 | 274 | if isinstance(username, str): 275 | profile_request = requests.get('https://namemc.com/profile/' + username) #gets websites code or scrapes it 276 | 277 | if isinstance(uuid, str): 278 | profile_request = requests.get('https://namemc.com/profile/' + str(uuid)) #gets websites code or scrapes it 279 | 280 | soup = BeautifulSoup(profile_request.text, 'html.parser') 281 | skin_scrape = soup.find_all('div', class_='card-body text-center') # searches for div in the specified class 282 | 283 | for usedskins in skin_scrape: 284 | for skin_hashes in usedskins.find_all('a', href=True): 285 | skin_hash_list.append(skin_hashes['href']) 286 | if 'javascript:void(0)' in skin_hash_list: 287 | skin_hash_list.remove('javascript:void(0)') # just have to get rid of something that stays in the code idk y 288 | 289 | if current == False: 290 | pass 291 | 292 | for s in skin_hash_list: 293 | final = s.lstrip('/skin/') 294 | final_list.append(final) 295 | 296 | if current == False: 297 | return final_list 298 | if current == True: 299 | return final_list[0] 300 | 301 | def nameDrop(self, name): #thanks eslam for the code :) 302 | r = requests.get(self.drop + name) 303 | soup = BeautifulSoup(r.text, 'html.parser') 304 | texts = soup.findAll(text=True) 305 | digits = ''.join([i for i in texts[0] if i.isdigit()]) 306 | droptime = datetime.fromtimestamp(int(digits)).strftime('%H:%M:%S') 307 | print("Name will drop on", droptime) 308 | 309 | def renderSkin(self, skinhash, model, x=False, y=False, directon=False, time=False): 310 | 311 | if directon=='front' and model=='slim' and time==False: 312 | url = 'https://render.namemc.com/skin/3d/body.png?skin=' + skinhash + '&model=slim&theta=0&phi=0&time=0&width=600&height=800' 313 | 314 | if directon=='front' and model=='slim' and isinstance(time, str): 315 | url = 'https://render.namemc.com/skin/3d/body.png?skin=' + skinhash + '&model=slim&theta=0&phi=0&time=' + time + '&width=600&height=800' 316 | 317 | if directon=='front' and model=='big' and time==False: 318 | url = 'https://render.namemc.com/skin/3d/body.png?skin=' + skinhash + '&model=big&theta=0&phi=0&time=0&width=600&height=800' 319 | 320 | if directon=='front' and model=='big' and isinstance(time, str): 321 | url = 'https://render.namemc.com/skin/3d/body.png?skin=' + skinhash + '&model=big&theta=0&phi=0&time=' + time + '&width=600&height=800' 322 | 323 | if isinstance(x, str) and isinstance(y, str) and directon==False and isinstance(time, str): 324 | url = 'https://render.namemc.com/skin/3d/body.png?skin=' + skinhash + '&model='+ model + '&theta='+ x + '&phi='+ y + '&time=' + time + '&width=600&height=800' 325 | 326 | return url 327 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | with open("README.md", "r") as fh: 4 | long_description = fh.read() 5 | 6 | setuptools.setup( 7 | name="namemcpy", 8 | version="1.4.1", 9 | license="MIT", 10 | author="Luke Lass", 11 | author_email="ants.uk.us@gmail.com", 12 | description="Api Wrapper for namemc", 13 | long_description="Api Wrapper for https://namemc.com. This moudule is to make it easier to use namemcs api.", 14 | long_description_content_type="text/markdown", 15 | url="https://github.com/lasscat/namemcpy", 16 | packages=setuptools.find_packages(), 17 | install_requires = ["requests", "bs4"], 18 | classifiers=[ 19 | "Programming Language :: Python :: 3", 20 | "License :: OSI Approved :: MIT License", 21 | "Operating System :: OS Independent", 22 | ], 23 | python_requires='>=3.6' 24 | ) 25 | --------------------------------------------------------------------------------