Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Merge branch 'fix/opgg'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Blackman committed Nov 10, 2017
2 parents 66849fd + 3d08bbc commit 3e5c605
Show file tree
Hide file tree
Showing 21 changed files with 350 additions and 174 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

<a name="2.1.1" />
## 2.1.1 (November 10th, 2017)

#### Bug Fixes
- Fixed op.gg to work with updated website

<a name="2.1.0" />
## 2.1.0 (October 31st, 2017)

Expand Down
10 changes: 5 additions & 5 deletions data/csspaths.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
},
"opgg": {
"version": "body > div.LayoutWrap.CurrentMenu-champion > div.ContentWrap > div > div.PageHeaderWrap > div.PageDescription > span.Small",
"starter": "div.SideContent > div:nth-child(3) > div > table > tbody > tr",
"boots": "div.SideContent > div:nth-child(2) > div > table > tbody > tr",
"core": "div.SideContent > div:nth-child(1) > div > table > tbody > tr",
"items": "div.RealContent > div > div > table > tbody > tr",
"skills": "div > div > div > table > tbody > tr"
"starter": "div > div.l-champion-statistics-content__main > div:nth-child(3) > div > table > tbody > tr",
"boots": "div > div.l-champion-statistics-content__main > div:nth-child(2) > div > table > tbody > tr",
"core": "div > div.l-champion-statistics-content__main > div:nth-child(1) > div > table > tbody > tr",
"items": "div > div.l-champion-statistics-content__side > div > div > table > tbody > tr",
"skills": "div > div > div.tabItem.ChampionSkillPriorites-1 > table > tbody > tr"
},
"lolmasters": {
"version": "span:contains('Patch:')"
Expand Down
2 changes: 1 addition & 1 deletion i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"something_broke": "Κάτι έσπασε...",
"start_league": "Έναρξη League of Legends",
"starter": "Αρχικά",
"starting_items": "Αντικείμενα Εκκίνησης ",
"starting_items": "Αντικείμενα Εκκίνησης",
"status": "Κατάσταση",
"summoners_rift_source": "Επιλέξτε αντικείμενα για το Φαράγγι των Επικαλεστών",
"support": "Υποστηρικτής",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Championify",
"version": "2.1.0",
"version": "2.1.1",
"description": "Downloads all the recent builds from websites like Champion.gg and imports them in to League of Legends.",
"main": "electron.js",
"scripts": {
Expand Down
47 changes: 28 additions & 19 deletions src/sources/opgg.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const csspaths = require('../../data/csspaths.json');
const default_schema = require('../../data/default.json');
const prebuilts = require('../../data/prebuilts.json');

const skills_map = ['Q', 'W', 'E', 'R'];
const templates = {
combindedStart: (pickrate, winrate) => `${T.t('frequent', true)}/${T.t('highest_start', true)} - Winrate: ${winrate}, Pickrate: ${pickrate}%`,
combinedCore: (pickrate, winrate) => `${T.t('frequent', true)}/${T.t('highest_core', true)} - Winrate: ${winrate}%, Pickrate: ${pickrate}%`,
Expand Down Expand Up @@ -55,7 +54,7 @@ function createSituationalItemsBlock(templateFunc, rate_type, items) {
const sorted = R.reverse(R.sortBy(R.prop(rate_type), items));
const rate = `${sorted[0][rate_type]}-${sorted[5][rate_type]}`;
return {
items: arrayToBuilds(R.pluck('items', sorted).slice(0, 5)),
items: arrayToBuilds(R.pluck('items', sorted).slice(0, 6)),
type: templateFunc(rate),
rate
};
Expand Down Expand Up @@ -89,11 +88,28 @@ function mapItems($, selector) {
el = $(el);
const items = el.find('img')
.map((idx, item_el) => R.last($(item_el).attr('src').split('/')).split('.')[0])
.filter(entry => entry !== 'blet')
.get();
const pickrate = Number(el.find('.PickRate').eq(0).contents().filter(function() {
return this.type === 'text';
}).text().replace(/[^0-9.]/g, ''));
const winrate = Number(el.find('.WinRate').eq(0).text().replace(/[^0-9.]/g, ''));

const pickrate = Number(el
.find('.champion-stats__table__cell--pickrate')
.eq(0)
.contents()
.filter(function() {
return this.type === 'text';
})
.text()
.split('%')[0]
.replace(/[^0-9.]/g, '')
.trim()
);

const winrate = Number(el
.find('.champion-stats__table__cell--winrate')
.eq(0)
.text()
.replace(/[^0-9.]/g, '')
);

return {items, pickrate, winrate};
})
Expand All @@ -104,16 +120,9 @@ function mapSkills($, selector) {
const skills = $(selector)
.map((idx, el) => {
el = $(el);
const pickrate = el.find('.PickRate > div').text().trim().replace(/[^0-9.]/g, '');
const winrate = el.find('.WinRate').text().trim().replace(/[^0-9.]/g, '');
const skills = [];
el.find('.Row').each((idx, row) => {
const ability = skills_map[idx];
$(row).find('.LevelUP').map((idx, cell) => {
skills[Number($(cell).text().trim()) - 1] = ability;
});
});

const pickrate = el.find('.champion-stats__table__cell--pickrate').text().split('%')[0].replace(/[^0-9.]/g, '').trim() + '%';
const winrate = el.find('.champion-stats__table__cell--winrate').text().split('%')[0].replace(/[^0-9.]/g, '').trim() + '%';
const skills = el.find('tr').eq(1).text().replace(/[^A-Z]/g, '').split('');
return {skills, pickrate, winrate};
})
.get();
Expand Down Expand Up @@ -147,7 +156,7 @@ function _makeRequest(url) {
export function getVersion() {
return request('https://www.op.gg/champion/ahri/statistics/mid')
.then(cheerio.load)
.then($ => R.last($('span.Small').text().split(': ')))
.then($ => R.last($('.champion-stats-header-version').text().split(':')).trim())
.tap(version => store.set('opgg_ver', version));
}

Expand All @@ -156,8 +165,8 @@ export function getSr() {

return _makeRequest('https://www.op.gg/champion/statistics')
.then($ => {
return $('.ChampionIndexGrid')
.find('.Item')
return $('.champion-index__champion-list')
.find('.champion-index__champion-item')
.map((idx, el) => {
el = $(el);
return {
Expand Down
1 change: 1 addition & 0 deletions tests/sources/fixtures/opgg/responses/ahri_statistics.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/sources/fixtures/opgg/responses/item.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/sources/fixtures/opgg/responses/skill.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/sources/fixtures/opgg/responses/statistics.html

This file was deleted.

1 change: 1 addition & 0 deletions tests/sources/fixtures/opgg/responses/stats.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"count": 1
}
],
"type": "Consumables | Frequent: Q.E.W.Q.Q.R.Q.E.Q.E.R.E.E.W.W"
"type": "Consumables | Frequent: Q.W.E.Q.Q.R.Q.W.Q.W.R.W.W.E.E"
},
{
"items": [
Expand All @@ -70,7 +70,7 @@
"count": 1
}
],
"type": "Most Frequent Starters - Pickrate: 61.02%"
"type": "Most Frequent Starters - Pickrate: 95.86%"
},
{
"items": [
Expand All @@ -95,49 +95,57 @@
"count": 1
}
],
"type": "Highest Win % Starters - Winrate: 64.29%"
"type": "Highest Win % Starters - Winrate: 59.68%"
},
{
"items": [
{
"id": "3165",
"count": 1
},
{
"id": "blet",
"count": 2
},
{
"id": "3285",
"count": 1
},
{
"id": "3089",
"id": "3157",
"count": 1
},
{
"id": "3020",
"count": 1
}
],
"type": "Most Frequent Core Build - Pickrate: 7.12%"
"type": "Most Frequent Core Build - Pickrate: 9.47%"
},
{
"items": [
{
"id": "3165",
"count": 1
},
{
"id": "blet",
"count": 2
},
{
"id": "3285",
"count": 1
},
{
"id": "3089",
"id": "3151",
"count": 1
},
{
"id": "3158",
"id": "3020",
"count": 1
}
],
"type": "Highest Win % Core Build - Winrate: 68.73%"
"type": "Highest Win % Core Build - Winrate: 68.81%"
},
{
"items": [
Expand All @@ -158,11 +166,15 @@
"count": 1
},
{
"id": "3001",
"id": "3157",
"count": 1
},
{
"id": "1026",
"count": 1
}
],
"type": "Most Frequent Items - Pickrate: 15.66-5.91%"
"type": "Most Frequent Items - Pickrate: 15.78-4.07%"
},
{
"items": [
Expand All @@ -171,26 +183,30 @@
"count": 1
},
{
"id": "3100",
"id": "3151",
"count": 1
},
{
"id": "3116",
"count": 1
},
{
"id": "3089",
"count": 1
},
{
"id": "3152",
"id": "3135",
"count": 1
},
{
"id": "3285",
"count": 1
}
],
"type": "Highest Win % Items - Winrate: 76.73-58.84%"
"type": "Highest Win % Items - Winrate: 76.63-55.33%"
}
],
"title": "OPGG Middle 6.22",
"title": "OPGG Middle 7.21",
"priority": false,
"mode": "any",
"type": "custom",
Expand Down
Loading

0 comments on commit 3e5c605

Please sign in to comment.