{"id":335759,"date":"2022-07-15T15:00:16","date_gmt":"2022-07-15T15:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=335759"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=335759","title":{"rendered":"<span>\u0427\u0430\u0441\u0442\u044c 2. \u041f\u0438\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043c\u0430\u0442\u0447\u0435\u0439 Dota 2 \u043d\u0430 Celery \u0438 Flask<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/672420\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u043b\u0438 \u0440\u0435\u043f\u043b\u0435\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0447\u0430 \u043f\u043e Dota 2 \u0438 \u043d\u0430\u0448\u043b\u0438 \u0445\u0430\u0439\u043b\u0430\u0439\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0440\u0435\u043f\u043b\u0435\u0435\u0432 \u043d\u0430 Celery \u0438 Flask.<\/p>\n<h2>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c<\/h2>\n<ol>\n<li>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u043c\u0430\u0442\u0447\u0435\u0439 The International 2021.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u043c\u0430\u0442\u0447\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Celery.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0438\u0448\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 API \u043d\u0430 Flask.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u043e\u0434 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u043c\u0430\u0442\u0447\u0435\u0439 The International 2021<\/h2>\n<p>\u041a\u0430\u0447\u0430\u0442\u044c \u0440\u0435\u043f\u0435\u043b\u0435\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u0433\u0440\u044b \u2014 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f, \u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0443\u0434\u043d\u0430\u044f \u0434\u043b\u044f \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0438 \u0441\u043e\u0442\u0435\u043d \u043c\u0430\u0442\u0447\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0438\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u0434\u043e\u0441\u0442\u0430\u043d\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u0447\u0435\u0440\u0435\u0437 OpenDota API.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0437\u043d\u0430\u0442\u044c <code>Tournament ID<\/code> \u0434\u043b\u044f TI 2021. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 Dotabuff, \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0442\u0443\u0440\u043d\u0438\u0440\u0430 \u0438 \u043f\u0440\u0438\u0441\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 URL.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d99\/ea2\/95c\/d99ea295cc4c8f8da674089c2298394a.png\" alt=\"\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 TI2021 \u043d\u0430 Dotabuff\" title=\"\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 TI2021 \u043d\u0430 Dotabuff\" width=\"1096\" height=\"66\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d99\/ea2\/95c\/d99ea295cc4c8f8da674089c2298394a.png\"\/><figcaption>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 TI2021 \u043d\u0430 Dotabuff<\/figcaption><\/figure>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c <code>Match ID<\/code> \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0432\u0441\u0435\u0445 \u043c\u0430\u0442\u0447\u0435\u0439 \u0441 \u0442\u0443\u0440\u043d\u0438\u0440\u0430.<\/p>\n<pre><code class=\"python\">import requests  tournament_id = 13256 r = requests.get(   f'https:\/\/api.opendota.com\/api\/leagues\/{tournament_id}\/matches') matches = r.json() len(matches)  > 487<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0430\u0442\u0447\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 Replay API. \u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f API \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e 60 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443.<\/p>\n<pre><code class=\"python\">import time  limit = 14 replays = [] for i, m in enumerate(matches):     if i == limit:         break          match_id = m['match_id']     r = requests.get(       'https:\/\/api.opendota.com\/api\/replays\/',        params=dict(match_id=match_id)     )     r.raise_for_status()     replays.append(r.json())     time.sleep(0.05)      replays > [    [{'match_id': 6078908851, 'cluster': 236, 'replay_salt': 908561694}],    [{'match_id': 6056286110, 'cluster': 187, 'replay_salt': 1627987562}],   ...<\/code><\/pre>\n<p>\u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d<\/p>\n<p><code>http:\/\/replay{cluster}.valve.net\/570\/{match_id}_{replay_salt}.dem.bz2<\/code>.<\/p>\n<p>\u041d\u044e\u0430\u043d\u0441 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438, \u0442.\u043a. \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0430\u0442\u0447\u0430\u0445 \u0438\u0433\u0440\u043e\u043a\u0438 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u043b\u043e\u0431\u0431\u0438. \u041e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0438\u0445, \u0441\u0434\u0435\u043b\u0430\u0432 HEAD \u0437\u0430\u043f\u0440\u043e\u0441\u044b. <\/p>\n<pre><code class=\"python\">urls = [] for replay in replays:     cluster = replay[0]['cluster']     match_id = replay[0]['match_id']     replay_salt = replay[0]['replay_salt']     url = f'http:\/\/replay{cluster}.valve.net\/570\/{match_id}_{replay_salt}.dem.bz2'      r = requests.head(url)     print(f'Status: {r.status_code}, URL: {url}')     if r.status_code == 200:         urls.append(url) len(urls) > 10<\/code><\/pre>\n<p>\u0418\u0437 \u043f\u0435\u0440\u0432\u044b\u0445 14 \u0441\u0441\u044b\u043b\u043e\u043a 10 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438. \u0412\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430, \u0442.\u043a. \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043e\u0434\u0438\u043d <code>.dem<\/code> \u0440\u0435\u043f\u043b\u0435\u0439 \u0432\u0435\u0441\u0438\u0442 100 MB.<\/p>\n<h2>\u0420\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0440\u0435\u043f\u043b\u0435\u0435\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Celery<\/h2>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 <code>Celery<\/code>, \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 <code>Redis<\/code>. \u0412\u043e\u0440\u043a\u0435\u0440\u044b \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0430 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f <code>Celery<\/code>.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"bash\">$ tree -P '*.py' -I '__pycache__' src\/  \u251c\u2500\u2500 async_parser \u2502\u00a0\u00a0 \u251c\u2500\u2500 celery.py \u2502\u00a0\u00a0 \u2514\u2500\u2500 tasks.py \u251c\u2500\u2500 server.py \u251c\u2500\u2500 settings.py \u2514\u2500\u2500 sync_parser.py  1 directory, 5 files<\/code><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0432\u044b\u0436\u0438\u043c\u043a\u0443 \u043a\u043e\u0434\u0430. \u041f\u043e\u043b\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h4>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c <code>Redis<\/code>.<\/p>\n<pre><code>sudo docker run --name dota-redis -p 6379:6379 -d redis<\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0443 5600 <code>Clarity Parser<\/code>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0435\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/arch1baald\/clarity-parser.git parser sudo docker build -t odota\/parser parser\/ sudo docker run -d --name clarity-parser -p 5600:5600 odota\/parser<\/code><\/pre>\n<p><strong>\u0421\u0443\u0442\u044c<\/strong><\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>celery.py<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Celery<\/code>.<\/p>\n<pre><code class=\"python\">from celery import Celery  app = Celery(     'async_parser',     broker=REDIS_URL,     backend=REDIS_URL,     include=['async_parser.tasks'],     accept=['json'] )  app.start()<\/code><\/pre>\n<p>\u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>tasks.py<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<ol>\n<li>\n<p><code>download_save(URL)<\/code> \u2014 \u0421\u043a\u0430\u0447\u0430\u0442\u044c <code>.dem<\/code> \u0440\u0435\u043f\u043b\u0435\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e<\/p>\n<\/li>\n<li>\n<p><code>parse(dem_path)<\/code> \u2014 \u041f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0440\u0435\u043f\u043b\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 Clarity Parser, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u043e\u0433 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>.jsonlines<\/code> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430\u0441\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0440\u0435\u043f\u043b\u0435\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <code>celery.chain()<\/code>.<\/p>\n<h4>1. \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0440\u0435\u043f\u043b\u0435\u044f<\/h4>\n<p>\u0417\u0430\u0434\u0430\u0447\u0438 \u0434\u043b\u044f Celery \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c <code>@app.task()<\/code>.<\/p>\n<pre><code class=\"python\">def download(url):     logger.info(f'Downloading: {url}...')     r = requests.get(url)     r.raise_for_status()          compressed_dem = r.content     logger.info(f'Decompressing: {url}...')     dem = decompress(compressed_dem)     return dem   @app.task() def download_save(url):     right = url.split('\/')[-1]     match_salt = right.replace('dem.bz2', '')     file_name = match_salt.split('_')[0]     file_name += '.dem'     path = os.path.join(REPLAY_DIR, file_name)          if os.path.exists(path):         logger.info(f'Dem file already exists: {path}...')         return path      dem = download(url)     with open(path, 'wb') as fout:         fout.write(dem)     logger.info(f'Saved to {path}...')     return path<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0442\u044c Redis, \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0440\u0435\u043f\u043b\u0435\u044f \u043d\u0430 \u0434\u0438\u0441\u043a\u0435, \u0430 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0430\u0442\u0447\u0438 \u0441 \u0442\u0443\u0440\u043d\u0438\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c S3 \u0432\u043c\u0435\u0441\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430.<\/p>\n<h4>2. \u041f\u0430\u0440\u0441\u0438\u043d\u0433<\/h4>\n<pre><code class=\"python\">@app.task() def parse(dem_path, remove_dem=False):     jsonlines_path = dem_path.replace('.dem', '.jsonlines')      logger.info(f'Parsing {jsonlines_path}...')     cmd = f'curl localhost:5600 --data-binary \"@{dem_path}\" > {jsonlines_path}'     subprocess.run(cmd, shell=True)      if os.path.getsize(jsonlines_path) == 0:         os.remove(jsonlines_path)         raise ClarityParserException(             f'Result file is empty: {jsonlines_path}...\\nDid you forget to run odota\/parser?')          if os.path.exists(dem_path) and remove_dem:         logger.info(f'Removing temporary file {dem_path}...')         os.remove(dem_path)     return jsonlines_path<\/code><\/pre>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 <code>parse<\/code> \u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>dem_path<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>chain<\/code> \u0441\u0430\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 <code>download_save.s(url)<\/code>. <\/p>\n<pre><code class=\"python\">def download_parse_save(url):     res = chain(download_save.s(url), parse.s())()     return res<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c Celery.<\/p>\n<pre><code class=\"bash\">celery -A async_parser worker -l INFO<\/code><\/pre>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 API \u043d\u0430 Flask<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u043f\u0443\u0441\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0439 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>server.py<\/code> \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u0440\u0443\u0447\u043a\u0438 <code>localhost:5000\/parse<\/code>.<\/p>\n<pre><code class=\"python\">from flask import Flask, request, jsonify  from async_parser.tasks import download_parse_save   app = Flask(__name__)   @app.route('\/parse') def parse():     dem_url = request.args.get('url')     logger.info(f'{dem_url=}')     if dem_url is None:         return jsonify(dict(             success=False,              error='Demo URL not found'         )), 400      async_result = download_parse_save(dem_url)     logger.info(f'{async_result}')     return jsonify(dict(         success=True,         url=dem_url,         job_id=async_result.id     ))<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440. <\/p>\n<pre><code class=\"bash\">FLASK_APP=server flask run<\/code><\/pre>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433<\/h2>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443.<\/p>\n<pre><code class=\"bash\">curl -X GET 'http:\/\/localhost:5000\/parse?url=http:\/\/replay191.valve.net\/570\/6216665747_89886887.dem.bz2'<\/code><\/pre>\n<ul>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Flask API \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>download_parse_save(dem_url)<\/code><\/p>\n<\/li>\n<li>\n<p>Celery worker \u0432\u0438\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 <code>download_save(url)<\/code>, \u0438\u0434\u0435\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <code>http:\/\/replay191.valve.net\/570\/6216665747_89886887.dem.bz2<\/code> \u043d\u0430 CDN Valve, \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0435\u043f\u043b\u0435\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>Celery worker \u0432\u0438\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 <code>parse(dem_path)<\/code> \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a Clarity Parser<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b Clarity Parser \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>.jsonlines<\/code> \u043b\u043e\u0433\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c 10 \u043c\u0430\u0442\u0447\u0435\u0439 \u0441 The International 2021, \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n<pre><code class=\"python\">with open(os.path.join(REPLAY_DIR, 'urls.txt'), 'r') as fin:   for url in fin:     url = url.strip()      try:       r = requests.get('http:\/\/localhost:5000\/parse', params=dict(url=url))       r.raise_for_status()       except Exception as e:         logger.info(e)         continue          logger.info(r.json())         time.sleep(0.05)<\/code><\/pre>\n<p>\u041e\u0442\u043e\u0439\u0434\u0435\u043c \u043d\u0430 \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442, \u043d\u0430\u043b\u044c\u0435\u043c \u0447\u0430\u044e, \u0430 \u043f\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043c \u0444\u0430\u0439\u043b\u044b \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"bash\">ls replays  6066863360.jsonlines6215020578.jsonlines6216545156.jsonlines6227492909.jsonlines 6079386505.jsonlines6215346651.jsonlines6216665747.jsonlinesurls.txt 6214179880.jsonlines6216526891.jsonlines6227203516.jsonlines<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a31\/761\/633\/a317616333deec94628957ad1c69943e.png\" width=\"1378\" height=\"554\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a31\/761\/633\/a317616333deec94628957ad1c69943e.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u0412\u044b \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e \u2014 \u0432\u044b \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u044b. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u043e\u0442\u043d\u0438 \u043c\u0430\u0442\u0447\u0435\u0439 \u043f\u043e Dota 2 \u0437\u0430 \u0440\u0430\u0437\u0443\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0445\u0430\u0439\u043b\u0430\u0439\u0442\u043e\u0432, \u0443\u043b\u0443\u0447\u0448\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u043e\u0431\u043a\u0430\u0442\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0430\u0442\u0447\u0430\u0445.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/arch1baald\/dota-highlights\/tree\/paper-2\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 GitHub (\u0432\u0435\u0442\u043a\u0430 paper-2)<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.opendota.com\/#tag\/leagues%2Fpaths%2F~1leagues~1%7Bleague_id%7D~1matches%2Fget\" rel=\"noopener noreferrer nofollow\">OpenDota League Matches API<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.dotabuff.com\/esports\/leagues\/13256-the-international-2021\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0442\u0443\u0440\u043d\u0438\u0440\u0430 \u043d\u0430 Dotabuff<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/arch1baald\/dota-highlights\/blob\/paper-2\/scripts\/retrieve_match_urls.py\" rel=\"noopener noreferrer nofollow\">\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043c\u0430\u0442\u0447\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/677200\/\"> https:\/\/habr.com\/ru\/post\/677200\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/672420\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u043b\u0438 \u0440\u0435\u043f\u043b\u0435\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0447\u0430 \u043f\u043e Dota 2 \u0438 \u043d\u0430\u0448\u043b\u0438 \u0445\u0430\u0439\u043b\u0430\u0439\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0440\u0435\u043f\u043b\u0435\u0435\u0432 \u043d\u0430 Celery \u0438 Flask.<\/p>\n<h2>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c<\/h2>\n<ol>\n<li>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u043c\u0430\u0442\u0447\u0435\u0439 The International 2021.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u043c\u0430\u0442\u0447\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Celery.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0438\u0448\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 API \u043d\u0430 Flask.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u043e\u0434 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u043c\u0430\u0442\u0447\u0435\u0439 The International 2021<\/h2>\n<p>\u041a\u0430\u0447\u0430\u0442\u044c \u0440\u0435\u043f\u0435\u043b\u0435\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u0433\u0440\u044b \u2014 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f, \u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0443\u0434\u043d\u0430\u044f \u0434\u043b\u044f \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0438 \u0441\u043e\u0442\u0435\u043d \u043c\u0430\u0442\u0447\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0438\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u0434\u043e\u0441\u0442\u0430\u043d\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u0447\u0435\u0440\u0435\u0437 OpenDota API.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0437\u043d\u0430\u0442\u044c <code>Tournament ID<\/code> \u0434\u043b\u044f TI 2021. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 Dotabuff, \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0442\u0443\u0440\u043d\u0438\u0440\u0430 \u0438 \u043f\u0440\u0438\u0441\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 URL.<\/p>\n<figure class=\"full-width\"><figcaption>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 TI2021 \u043d\u0430 Dotabuff<\/figcaption><\/figure>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c <code>Match ID<\/code> \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0432\u0441\u0435\u0445 \u043c\u0430\u0442\u0447\u0435\u0439 \u0441 \u0442\u0443\u0440\u043d\u0438\u0440\u0430.<\/p>\n<pre><code class=\"python\">import requests  tournament_id = 13256 r = requests.get(   f'https:\/\/api.opendota.com\/api\/leagues\/{tournament_id}\/matches') matches = r.json() len(matches)  > 487<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0430\u0442\u0447\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 Replay API. \u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f API \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e 60 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443.<\/p>\n<pre><code class=\"python\">import time  limit = 14 replays = [] for i, m in enumerate(matches):     if i == limit:         break          match_id = m['match_id']     r = requests.get(       'https:\/\/api.opendota.com\/api\/replays\/',        params=dict(match_id=match_id)     )     r.raise_for_status()     replays.append(r.json())     time.sleep(0.05)      replays > [    [{'match_id': 6078908851, 'cluster': 236, 'replay_salt': 908561694}],    [{'match_id': 6056286110, 'cluster': 187, 'replay_salt': 1627987562}],   ...<\/code><\/pre>\n<p>\u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d<\/p>\n<p><code>http:\/\/replay{cluster}.valve.net\/570\/{match_id}_{replay_salt}.dem.bz2<\/code>.<\/p>\n<p>\u041d\u044e\u0430\u043d\u0441 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438, \u0442.\u043a. \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0430\u0442\u0447\u0430\u0445 \u0438\u0433\u0440\u043e\u043a\u0438 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u043b\u043e\u0431\u0431\u0438. \u041e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0438\u0445, \u0441\u0434\u0435\u043b\u0430\u0432 HEAD \u0437\u0430\u043f\u0440\u043e\u0441\u044b. <\/p>\n<pre><code class=\"python\">urls = [] for replay in replays:     cluster = replay[0]['cluster']     match_id = replay[0]['match_id']     replay_salt = replay[0]['replay_salt']     url = f'http:\/\/replay{cluster}.valve.net\/570\/{match_id}_{replay_salt}.dem.bz2'      r = requests.head(url)     print(f'Status: {r.status_code}, URL: {url}')     if r.status_code == 200:         urls.append(url) len(urls) > 10<\/code><\/pre>\n<p>\u0418\u0437 \u043f\u0435\u0440\u0432\u044b\u0445 14 \u0441\u0441\u044b\u043b\u043e\u043a 10 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438. \u0412\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430, \u0442.\u043a. \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043e\u0434\u0438\u043d <code>.dem<\/code> \u0440\u0435\u043f\u043b\u0435\u0439 \u0432\u0435\u0441\u0438\u0442 100 MB.<\/p>\n<h2>\u0420\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0440\u0435\u043f\u043b\u0435\u0435\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Celery<\/h2>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 <code>Celery<\/code>, \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 <code>Redis<\/code>. \u0412\u043e\u0440\u043a\u0435\u0440\u044b \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0430 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f <code>Celery<\/code>.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"bash\">$ tree -P '*.py' -I '__pycache__' src\/  \u251c\u2500\u2500 async_parser \u2502\u00a0\u00a0 \u251c\u2500\u2500 celery.py \u2502\u00a0\u00a0 \u2514\u2500\u2500 tasks.py \u251c\u2500\u2500 server.py \u251c\u2500\u2500 settings.py \u2514\u2500\u2500 sync_parser.py  1 directory, 5 files<\/code><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0432\u044b\u0436\u0438\u043c\u043a\u0443 \u043a\u043e\u0434\u0430. \u041f\u043e\u043b\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h4>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c <code>Redis<\/code>.<\/p>\n<pre><code>sudo docker run --name dota-redis -p 6379:6379 -d redis<\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0443 5600 <code>Clarity Parser<\/code>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0435\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/arch1baald\/clarity-parser.git parser sudo docker build -t odota\/parser parser\/ sudo docker run -d --name clarity-parser -p 5600:5600 odota\/parser<\/code><\/pre>\n<p><strong>\u0421\u0443\u0442\u044c<\/strong><\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>celery.py<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Celery<\/code>.<\/p>\n<pre><code class=\"python\">from celery import Celery  app = Celery(     'async_parser',     broker=REDIS_URL,     backend=REDIS_URL,     include=['async_parser.tasks'],     accept=['json'] )  app.start()<\/code><\/pre>\n<p>\u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>tasks.py<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<ol>\n<li>\n<p><code>download_save(URL)<\/code> \u2014 \u0421\u043a\u0430\u0447\u0430\u0442\u044c <code>.dem<\/code> \u0440\u0435\u043f\u043b\u0435\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e<\/p>\n<\/li>\n<li>\n<p><code>parse(dem_path)<\/code> \u2014 \u041f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0440\u0435\u043f\u043b\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 Clarity Parser, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u043e\u0433 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>.jsonlines<\/code> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u043d\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430\u0441\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0440\u0435\u043f\u043b\u0435\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <code>celery.chain()<\/code>.<\/p>\n<h4>1. \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0440\u0435\u043f\u043b\u0435\u044f<\/h4>\n<p>\u0417\u0430\u0434\u0430\u0447\u0438 \u0434\u043b\u044f Celery \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c <code>@app.task()<\/code>.<\/p>\n<pre><code class=\"python\">def download(url):     logger.info(f'Downloading: {url}...')     r = requests.get(url)     r.raise_for_status()          compressed_dem = r.content     logger.info(f'Decompressing: {url}...')     dem = decompress(compressed_dem)     return dem   @app.task() def download_save(url):     right = url.split('\/')[-1]     match_salt = right.replace('dem.bz2', '')     file_name = match_salt.split('_')[0]     file_name += '.dem'     path = os.path.join(REPLAY_DIR, file_name)          if os.path.exists(path):         logger.info(f'Dem file already exists: {path}...')         return path      dem = download(url)     with open(path, 'wb') as fout:         fout.write(dem)     logger.info(f'Saved to {path}...')     return path<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0442\u044c Redis, \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0440\u0435\u043f\u043b\u0435\u044f \u043d\u0430 \u0434\u0438\u0441\u043a\u0435, \u0430 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0430\u0442\u0447\u0438 \u0441 \u0442\u0443\u0440\u043d\u0438\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c S3 \u0432\u043c\u0435\u0441\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430.<\/p>\n<h4>2. \u041f\u0430\u0440\u0441\u0438\u043d\u0433<\/h4>\n<pre><code class=\"python\">@app.task() def parse(dem_path, remove_dem=False):     jsonlines_path = dem_path.replace('.dem', '.jsonlines')      logger.info(f'Parsing {jsonlines_path}...')     cmd = f'curl localhost:5600 --data-binary \"@{dem_path}\" > {jsonlines_path}'     subprocess.run(cmd, shell=True)      if os.path.getsize(jsonlines_path) == 0:         os.remove(jsonlines_path)         raise ClarityParserException(             f'Result file is empty: {jsonlines_path}...\\nDid you forget to run odota\/parser?')          if os.path.exists(dem_path) and remove_dem:         logger.info(f'Removing temporary file {dem_path}...')         os.remove(dem_path)     return jsonlines_path<\/code><\/pre>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 <code>parse<\/code> \u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>dem_path<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>chain<\/code> \u0441\u0430\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 <code>download_save.s(url)<\/code>. <\/p>\n<pre><code class=\"python\">def download_parse_save(url):     res = chain(download_save.s(url), parse.s())()     return res<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c Celery.<\/p>\n<pre><code class=\"bash\">celery -A async_parser worker -l INFO<\/code><\/pre>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 API \u043d\u0430 Flask<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u043f\u0443\u0441\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 API, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u0435\u043f\u043b\u0435\u0439 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>server.py<\/code> \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u0440\u0443\u0447\u043a\u0438 <code>localhost:5000\/parse<\/code>.<\/p>\n<pre><code class=\"python\">from flask import Flask, request, jsonify  from async_parser.tasks import download_parse_save   app = Flask(__name__)   @app.route('\/parse') def parse():     dem_url = request.args.get('url')     logger.info(f'{dem_url=}')     if dem_url is None:         return jsonify(dict(             success=False,              error='Demo URL not found'         )), 400      async_result = download_parse_save(dem_url)     logger.info(f'{async_result}')     return jsonify(dict(         success=True,         url=dem_url,         job_id=async_result.id     ))<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440. <\/p>\n<pre><code class=\"bash\">FLASK_APP=server flask run<\/code><\/pre>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433<\/h2>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443.<\/p>\n<pre><code class=\"bash\">curl -X GET 'http:\/\/localhost:5000\/parse?url=http:\/\/replay191.valve.net\/570\/6216665747_89886887.dem.bz2'<\/code><\/pre>\n<ul>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Flask API \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>download_parse_save(dem_url)<\/code><\/p>\n<\/li>\n<li>\n<p>Celery worker \u0432\u0438\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 <code>download_save(url)<\/code>, \u0438\u0434\u0435\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <code>http:\/\/replay191.valve.net\/570\/6216665747_89886887.dem.bz2<\/code> \u043d\u0430 CDN Valve, \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0435\u043f\u043b\u0435\u0439 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/p>\n<\/li>\n<li>\n<p>Celery worker \u0432\u0438\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 <code>parse(dem_path)<\/code> \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a Clarity Parser<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b Clarity Parser \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>.jsonlines<\/code> \u043b\u043e\u0433\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c 10 \u043c\u0430\u0442\u0447\u0435\u0439 \u0441 The International 2021, \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n<pre><code class=\"python\">with open(os.path.join(REPLAY_DIR, 'urls.txt'), 'r') as fin:   for url in fin:     url = url.strip()      try:       r = requests.get('http:\/\/localhost:5000\/parse', params=dict(url=url))       r.raise_for_status()       except Exception as e:         logger.info(e)         continue          logger.info(r.json())         time.sleep(0.05)<\/code><\/pre>\n<p>\u041e\u0442\u043e\u0439\u0434\u0435\u043c \u043d\u0430 \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442, \u043d\u0430\u043b\u044c\u0435\u043c \u0447\u0430\u044e, \u0430 \u043f\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043c \u0444\u0430\u0439\u043b\u044b \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"bash\">ls replays  6066863360.jsonlines6215020578.jsonlines6216545156.jsonlines6227492909.jsonlines 6079386505.jsonlines6215346651.jsonlines6216665747.jsonlinesurls.txt 6214179880.jsonlines6216526891.jsonlines6227203516.jsonlines<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u0412\u044b \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e \u2014 \u0432\u044b \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u043d\u044b. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u043e\u0442\u043d\u0438 \u043c\u0430\u0442\u0447\u0435\u0439 \u043f\u043e Dota 2 \u0437\u0430 \u0440\u0430\u0437\u0443\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0445\u0430\u0439\u043b\u0430\u0439\u0442\u043e\u0432, \u0443\u043b\u0443\u0447\u0448\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u043e\u0431\u043a\u0430\u0442\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0430\u0442\u0447\u0430\u0445.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/arch1baald\/dota-highlights\/tree\/paper-2\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 GitHub (\u0432\u0435\u0442\u043a\u0430 paper-2)<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.opendota.com\/#tag\/leagues%2Fpaths%2F~1leagues~1%7Bleague_id%7D~1matches%2Fget\" rel=\"noopener noreferrer nofollow\">OpenDota League Matches API<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.dotabuff.com\/esports\/leagues\/13256-the-international-2021\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0442\u0443\u0440\u043d\u0438\u0440\u0430 \u043d\u0430 Dotabuff<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/arch1baald\/dota-highlights\/blob\/paper-2\/scripts\/retrieve_match_urls.py\" rel=\"noopener noreferrer nofollow\">\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043c\u0430\u0442\u0447\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/677200\/\"> https:\/\/habr.com\/ru\/post\/677200\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-335759","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=335759"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335759\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}