mtg-playerinfo 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,12 +89,12 @@ Example output:
89
89
 
90
90
  The following sites are currently supported based on HTML scraping and/or API calls. In general, API calls are preferred over scraping due to their higher reliability and independence from site structure changes.
91
91
 
92
- | Site | Method |
93
- |-----------------|------------------------|
94
- | Unity League | ✅Scraping |
95
- | MTG Elo Project | ✅Scraping |
96
- | Topdeck | ✅Scraping |
97
- | Melee | Scraping / 🚧API (#1) |
92
+ | Site | Method |
93
+ |-----------------|------------------------------------------------------------------------------|
94
+ | Unity League | ✅Scraping |
95
+ | MTG Elo Project | ✅Scraping |
96
+ | Topdeck | ✅Scraping |
97
+ | Melee | 🚧Scraping/API ([#1](https://github.com/bkimminich/mtg-playerinfo/issues/1)) |
98
98
 
99
99
  _Note: Some sites may have anti-bot protections that can lead to "Maximum number of redirects exceeded" or "403 Forbidden" errors depending on the execution environment._
100
100
 
package/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  const { program } = require('commander');
3
3
  const PlayerInfoManager = require('./src/index');
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mtg-playerinfo",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A simple NPM module and CLI tool to pull Magic: The Gathering player data from various sources",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -16,13 +16,14 @@ class MeleeFetcher {
16
16
  parseHtml(html, url, username) {
17
17
  const $ = cheerio.load(html);
18
18
  const name = $('span[style*="font-size: xx-large"]').first().text().trim() || username;
19
- const photo = $('.profile-button-column img').first().attr('src') || $('img.m-auto').attr('src');
19
+ // FIXME Photos cannot be loaded with unauthenticated requests from Melee.gg
20
+ // const photo = $('.profile-button-column img').first().attr('src') || $('img.m-auto').attr('src');
20
21
 
21
22
  const data = {
22
23
  source: 'Melee',
23
24
  url,
24
25
  name,
25
- photo: photo ? (photo.startsWith('http') ? photo : `https://melee.gg${photo}`) : null,
26
+ // photo: photo ? (photo.startsWith('http') ? photo : `https://melee.gg${photo}`) : null,
26
27
  details: { }
27
28
  };
28
29
 
@@ -70,10 +70,10 @@ class UnityLeagueFetcher {
70
70
  headers.forEach((header, i) => {
71
71
  if (header && values[i]) {
72
72
  let val = values[i];
73
- if (val.startsWith('#')) {
74
- val = val.substring(1);
73
+ val = val.replace(/\D/g, ''); // remove non-numeric characters to support #23->23, 1st->1, and 42nd->42 etc.
74
+ if (val) {
75
+ data.details[`Rank ${header}`] = val;
75
76
  }
76
- data.details[`Rank ${header}`] = val;
77
77
  }
78
78
  });
79
79
  }