디시인사이드 갤러리

마이너 갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

[정보] 조금 리뉴얼한 피피 서열표 소스코드

누비(39.127) 2021.05.21 12:23:37
조회 310 추천 1 댓글 2
														
import requests
import json
from tqdm import tqdm
import time
import math

class Beatmap():
    def __init__(self):
        self.totalscore=0
        self.peopleplayed=0
        self.title=""
        self.version=""
        self.mods=""
        self.keys=""
        self.stars=0
        self.imageurl=""
        
beatmaplist = {}
beatmaplist4k = {}
beatmaplist7k = {}
k4 = []
k7 = []
al = []


def getscore(usernum):
    errorcount = 0
    while True:
        try:
            if errorcount > 6:
                break
            url = "https://osu.ppy.sh/users/"+str(usernum)+"/scores/best?mode=mania&limit=50"
            html = requests.get(url)
            if html == '<Response [429]>':
                raise Exception('429 error')
            ob1 = html.json()
    
            for score in ob1:
                bm = score['beatmap']
                bms = score['beatmapset']
                bmimg = bms['covers']
                bmw = score['weight']
                b = Beatmap()
                bid=bm['id']*10
                if 'HT' in score['mods']:
                    bid += 1
                if 'DT' in score['mods']:
                    bid += 2
                if bid in beatmaplist:
                    beatmaplist[bid].peopleplayed += math.sqrt(bmw['percentage']*0.01)
                    beatmaplist[bid].totalpp += score['pp']*math.sqrt(bmw['percentage']*0.01)
                    # 같은 bid인 같은 객체가 수정되기에 동시에 수정됨. 
                    # 딕셔너리에 넣는것은 그 객체의 메모리 주소를 넣는것일뿐 객체를 복사하지 않기때문에 업데이트가 유지됨
                    continue
                b.totalpp = score['pp']*math.sqrt(bmw['percentage']*0.01)
                b.peopleplayed = math.sqrt(bmw['percentage']*0.01)
                b.title = bms['title']
                b.version = bm['version']
                if 'HT' in score['mods']:
                    b.mods = "HT"
                if 'DT' in score['mods']:
                    b.mods = "DT"
                b.stars = bm['difficulty_rating']
                b.imageurl = bmimg['list@2x']
                beatmaplist[bid] = b
                if bm['cs']==7:
                    b.keys = "7k"
                    beatmaplist7k[bid] = b
                elif bm['cs']==4:
                    b.keys = "4k"
                    beatmaplist4k[bid] = b
            break
        except Exception as e:
            print(" userpage error"+ str(i), e)
            print(html)
            print(url)
            time.sleep(5)
            errorcount +=1
    
    
def searchranker(key,page,rankerlist):
    while True:
        try:
            html = requests.get("https://osu.ppy.sh/rankings/mania/performance?filter=all&variant="+key+"&country=KR&page="+str(page))
            ob1 = html.text
            index = -1
            index2 = index
            while True:
                index = ob1.find('class="ranking-page-table__user-link-text js-usercard"\n                                data-user-id="', index + 1)
                index2 = ob1.find('"', index + 101)
                if index == -1:
                    break
                rankerlist.append(ob1[index+101:index2])
            break
        except:
            time.sleep(5)

def dict_sorter(dicta):
    dicta = dict(sorted(dicta.items(), key=lambda xfloat(x[1].totalpp)/float(x[1].peopleplayed), reverse=True))
    return dicta

def dict_decoder(lista):
    print("출력중...")
    f = open('ranking.txt''w'encoding="utf-8")
    f.write(str(len(k7))+"의 표본으로 조사한 서열표입니다. 어려울수록 위에 있습니다. ssapgosu 작성\n\n")
    for i in tqdm(range(len(lista))):
        f.write(str(i+1+"등. \n")
        f.write(lista[i][2].title +"  "+ lista[i][2].mods + "\n// " + lista[i][2].version +"( " +str(lista[i][0]+", " + lista[i][2].keys  + " )\n\n")

# for i in tqdm(range(250)):
#     searchranker('all',i+1,al)
#     time.sleep(1.4)

# for i in range(200):
#     searchranker('4k',i+1,k4)
def makerank(pgstart,pgend,key,interval):
    if key =='4k':
        keylist = k4
        keylistbm = beatmaplist4k
    if key =='7k':
        keylist = k4
        keylistbm = beatmaplist4k
    if key =='all':
        keylist = al
        keylistbm = beatmaplist

    for i in tqdm(range(pgstart,pgend)):
        searchranker(key,i+1,keylist)
    for i in keylist:
        getscore(i)
        time.sleep(interval)
        print(i)

    lista = []
    for key, value in keylistbm.items():
        a = [key, value]
        lista.append(a)
    for i in lista:
        a = round(float(i[1].totalpp/i[1].peopleplayed),4)
        i.insert(0,a)
    lista.sort(reverse=True)
    # dict_sorter(beatmaplist7k)
    dict_decoder(lista)

makerank(0,6,'7k',2)


추천 비추천

1

고정닉 1

0

댓글 영역

전체 댓글 0
등록순정렬 기준선택
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 말머리 제목 글쓴이 작성일 조회 추천
2868 설문 힘들게 성공한 만큼 절대 논란 안 만들 것 같은 스타는? 운영자 24/06/10 - -
2870 이슈 [디시人터뷰] 웃는 모습이 예쁜 누나, 아나운서 김나정 운영자 24/06/11 - -
2869 AD 딥 블루 호라이즌 사전예약 6.14-7.4 운영자 24/06/14 - -
111797 일반 Full BN 되었다 질문 받는다 [19] 누비_갤로그로 이동합니다. 23.06.26 563 11
111788 매핑 더타 1.98성, 정배 2.32성, 핲타 2.65성 (단일 난이도) [8] 누비_갤로그로 이동합니다. 23.06.25 323 3
111700 일반 Map4Check 오픈 [8] 누비_갤로그로 이동합니다. 23.06.23 288 7
111650 정보 [2023 랭곡 매핑 가이드] 2. BN 심사 [6] 누비_갤로그로 이동합니다. 23.06.22 685 21
111510 정보 [2023 랭곡 매핑 가이드] 1. 랭곡의 조건 [19] 누비_갤로그로 이동합니다. 23.06.18 994 40
110833 일반 디1맥 신곡은 과연 오스 매냐에서 랭이 될까? [18] 누비_갤로그로 이동합니다. 23.06.02 677 2
110489 일반 퀄파 보냈다 [3] 누비_갤로그로 이동합니다. 23.05.23 252 2
110428 일반 모딩큐 다 만들면 BN된 기념으로 갤 랭곡 몇개 뽑아볼까? [1] 누비_갤로그로 이동합니다. 23.05.21 297 5
110014 공지 모딩요청 말머리를 신설하였습니다. (+모딩이란?) [7] 누비_갤로그로 이동합니다. 23.05.09 554 15
109480 매핑 개쩌는 궁극기 연출 스토리보드 매핑 [10] 누비_갤로그로 이동합니다. 23.04.24 414 5
109134 이벤트 추첨 결과 [6] 누비_갤로그로 이동합니다. 23.04.16 304 8
108872 이벤트 싸이버거 5개 뿌린다 (이벤트 일요일 마감예정) [23] 누비_갤로그로 이동합니다. 23.04.11 1139 15
108873 일반 컬렉션 압축파일로 내보내는 프로그램 (베타) [1] 누비_갤로그로 이동합니다. 23.04.11 237 0
108622 일반 차단목록 5명 협상현황 [33] 누비_갤로그로 이동합니다. 23.04.05 904 8
108574 일반 아케이드마냥 오수콘 만드는중이다 (80%) [8] 누비_갤로그로 이동합니다. 23.04.04 382 8
108329 매핑 7키 5성 짜옴, 짧음.(체감 6성) 누비_갤로그로 이동합니다. 23.03.30 123 0
108092 일반 다 예상하는 그맵 1000pp 누비_갤로그로 이동합니다. 23.03.24 235 2
107824 정보 오스 공식 수록곡 수 집계 현황 [2] 누비_갤로그로 이동합니다. 23.03.19 413 7

게시물은 1만 개 단위로 검색됩니다.

갤러리 내부 검색
글쓴이게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2