Skip to content

league-of-legends-replay-extractor/pyLoL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

98 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


LoL Replay Extractor

!! LoL Replay Extractor is still in development, any bugs can appear !!

`LoL Replay Extractor ๐ŸŒŸ` is a program for gathering positional data and providing analytics from League of Legends videos. It can be used to automatically gather spatiotemporal data (player locations over time) from a series of Youtube/locally stored videos

โœ” Any PRs are welcome, Watch nightly branch for recent updates!

โœ…What is pyLoL?

pyLoL is 'League of Legends' replays data extracting program.

โœ…What can pyLoL do?

[1] can save replay files(.rofl) automatically.

[2] can get the location of players every one second.

[3] can get the location of wards.

๐Ÿš€Quickstart

  • youtube_guide

Video Label

Get started with pyLoL in nine steps:

Open In Colab

  1. First, clone this repository.
git clone https://github.com/league-of-legends-replay-extractor
  1. Install Requirements
pip install -r requirements.txt
  1. Make python project to Package
python setup.py develop
  1. Directory settings

    In replay_scraper.ipynb, modify the path to suit your local environment

    • game_dir: League of Legends game directory.
    • replay_dir: League of Legends *.rofl replay directory.
    • dataset_dir: JSON replay files output directory.
    • replay_speed: League of Legends client replay speed multiplier.
    • scraper_dir: Directory of the scraper program.
rd.set_replays_dir(rd,folder_dir = r'C:\Users\username\Documents\League of Legends\Replays')  # replay download directory

rs.__init__(rs, game_dir = r'C:\Riot Games\League of Legends\Game',                          
            replay_dir = r'C:\Users\username\Documents\League of Legends\Replays',               
            dataset_dir = r'C:\Users\username\Documents\League of Legends\Dataset',              
            scraper_dir = r'C:\Users\username\Desktop\pyLoL\pyLoL\autoLeague\replays',
            replay_speed=40,
            region="KR")
ie.__init__(ie,dataset_dir=r'C:\Users\username\Desktop\pyLoL')
  1. API KEY You can get API KEY from riot developer portal : https://developer.riotgames.com
dg.__init__(dg, api_key='RIOT_API_KEY' , count=20)
  1. Gathering MatchIds filtered by {queue, tier, division, max_ids, patch_start_datetime}

    if you wanna download matchIds from 5000 MASTER I in SOLORANK users in specific patch,

dg.get_tier_matchIds(dg, queue='RANKED_SOLO_5x5', tier='MASTER', division='I' , max_ids=5000, patch_start_datetime='2023.10.26')

image

  1. Save replay files for the match IDs obtained above
from tqdm import tqdm
import time

for matchId in tqdm(matchIds_challenger[:1000], 
                    desc = 'Gathering Replay_files(.rofl) from LoL Client... ', ## Print statement for progress at the front
                    ncols = 130, ## Adjust width for progress display
                    ascii = ' =', 
                    leave=True):
    
    try: #if this match id outdated, skip
        rd.download(rd, matchId)
        time.sleep(7)
    except:
        pass

image

  1. Run replay => Save minimap capture video
  • Option
    • All) no fog of war
    • Blue) fog of war in Blue team
    • Red) fog of war in Red team
for replay in tqdm(replays,
                    desc = 'Extracting Replay_Minimaps from LoL Client... ', ## Print statement for progress at the front
                    ncols = 200, ## Adjust width for progress display
                    ascii = ' =', 
                    leave=True
                    ):
    
    rs.run_client(rs,
                  replay_path = rf'{rs.get_replay_dir(rs)}\{replay}', 
                  gameId = replay.split('.')[0],
                  start=5*60 - 5, 
                  end=25*60 - 5, 
                  speed=10, 
                  paused=False, 
                  team="All")

image

  1. Extract Realtime KDA, CS using OCR
from autoLeague.preprocess.ocr_center_window import OcrCenter as oc
oc.__init__(oc, project_folder_dir = r'C:\Users\username\Desktop\pyLoL')
oc.get_ocr(oc)

image

๐ŸŽฏChampion Tracking Model( Using Minimap Frame dataset )

  • Champion Tracking (Roboflow)

Then, You can use this tracking model ( Performance | mAP : 92.2% | precision : 91.3% | recall : 90.2% )

  • Infer on Local and Hosted Images To install dependencies,

      pip install roboflow.
    

    Then, add the following the following code snippet to a Python script:

      from roboflow import Roboflow
      rf = Roboflow(api_key="API_KEY")
      project = rf.workspace().project("lolpago-multi-tracking-service")
      model = project.version(18).model
      
      # infer on a local image
      print(model.predict("your_image.jpg", confidence=40, overlap=30).json())
      
      # visualize your prediction
      # model.predict("your_image.jpg", confidence=40, overlap=30).save("prediction.jpg")
      
      # infer on an image hosted elsewhere
      # print(model.predict("URL_OF_YOUR_IMAGE", hosted=True, confidence=40, overlap=30).json())
    

image

๐ŸŒ Give this Project a Star

This project is an open source project. If you like what you see, please give it a star on github.

โ˜•Buy me a coffee

Buy Me A Coffee

๐Ÿ“Citing this Paper

Win Prediction in MOBA Games Using Time-Series Location Data : Case Study in League of Legends (LoL)

  @article{๊น€์„ฑ์œค2023์‹œ๊ณ„์—ด,
    title={์‹œ๊ณ„์—ด ์œ„์น˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ™œ์šฉํ•œ MOBA ๊ฒŒ์ž„ ์ŠนํŒจ ์˜ˆ์ธก: ๋ฆฌ๊ทธ์˜ค๋ธŒ๋ ˆ์ „๋“œ ์‚ฌ๋ก€ ๋ถ„์„},
    author={๊น€์„ฑ์œค and ์ดํƒœํ™ and ์–‘ํฌ์ฒ },
    journal={ํ•œ๊ตญํ†ต์‹ ํ•™ํšŒ ํ•™์ˆ ๋Œ€ํšŒ๋…ผ๋ฌธ์ง‘},
    pages={1205--1206},
    year={2023}
  }

image

kimsy1106 tim000519 cye_dev
developing replay extractor manage "read the docs" manage "read the docs"