dijs / wiki

Wikipedia Interface for Node.js
MIT License
313 stars 62 forks source link

Wrong main image when I'm searching for the france national football team #63

Closed kper closed 6 years ago

kper commented 6 years ago

The function findById returns the correct wikipedia page, but calling the function mainImage on the page returns mysteriously portugal's flag.

Output Page:

{ raw: 
   { pageid: 250197,
     ns: 0,
     title: 'France national football team',
     contentmodel: 'wikitext',
     pagelanguage: 'en',
     pagelanguagehtmlcode: 'en',
     pagelanguagedir: 'ltr',
     touched: '2017-10-16T08:45:09Z',
     lastrevid: 805578131,
     length: 90539,
     fullurl: 'https://en.wikipedia.org/wiki/France_national_football_team',
     editurl: 'https://en.wikipedia.org/w/index.php?title=France_national_football_team&action=edit',
     canonicalurl: 'https://en.wikipedia.org/wiki/France_national_football_team' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }

Output MainImage: https://upload.wikimedia.org/wikipedia/commons/5/5c/Flag_of_Portugal.svg

Code:

wiki()
    .findById(250197)
    .then(page => {
        console.log(page);
        page.mainImage().then((img) => {
            console.log(img);
        });
    });
dijs commented 6 years ago

It's because they are using "Badge" instead of "image" in their wiki code... I can't believe there are so many different ways to label your main image. This is so frustrating...

dijs commented 6 years ago

Fixed in v4.3.3

kper commented 6 years ago

I am sorry to tell you that I found more errors :/

Code:

var test = 879301; //you must replace this ID

wiki({apiUrl: 'https://de.wikipedia.org/w/api.php'})
    .findById(test)
    .then(page => {
        console.log(page);
        page.mainImage().then((img) => {
            console.log(img);
        });
    });
{ raw: 
   { pageid: 879301,
     ns: 0,
     title: 'FC Burnley',
     contentmodel: 'wikitext',
     pagelanguage: 'de',
     pagelanguagehtmlcode: 'de',
     pagelanguagedir: 'ltr',
     touched: '2017-10-01T15:38:08Z',
     lastrevid: 169252317,
     length: 51942,
     fullurl: 'https://de.wikipedia.org/wiki/FC_Burnley',
     editurl: 'https://de.wikipedia.org/w/index.php?title=FC_Burnley&action=edit',
     canonicalurl: 'https://de.wikipedia.org/wiki/FC_Burnley' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }
https://upload.wikimedia.org/wikipedia/commons/e/e6/Flag_of_Slovakia.svg
{ raw: 
   { pageid: 4484236,
     ns: 0,
     title: 'RB Leipzig',
     contentmodel: 'wikitext',
     pagelanguage: 'de',
     pagelanguagehtmlcode: 'de',
     pagelanguagedir: 'ltr',
     touched: '2017-10-15T09:17:42Z',
     lastrevid: 169992410,
     length: 107305,
     fullurl: 'https://de.wikipedia.org/wiki/RB_Leipzig',
     editurl: 'https://de.wikipedia.org/w/index.php?title=RB_Leipzig&action=edit',
     canonicalurl: 'https://de.wikipedia.org/wiki/RB_Leipzig' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }
https://upload.wikimedia.org/wikipedia/commons/b/b4/Flag_of_Turkey.svg

{ raw: 
   { pageid: 10023212,
     ns: 0,
     title: 'FC Bergheim',
     contentmodel: 'wikitext',
     pagelanguage: 'de',
     pagelanguagehtmlcode: 'de',
     pagelanguagedir: 'ltr',
     touched: '2017-10-09T15:48:57Z',
     lastrevid: 168583467,
     length: 19376,
     fullurl: 'https://de.wikipedia.org/wiki/FC_Bergheim',
     editurl: 'https://de.wikipedia.org/w/index.php?title=FC_Bergheim&action=edit',
     canonicalurl: 'https://de.wikipedia.org/wiki/FC_Bergheim' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }
https://upload.wikimedia.org/wikipedia/de/6/63/%C3%96FB-Frauenliga_%28%C3%96sterreich%29_Logo.jpg
{ raw: 
   { pageid: 6239591,
     ns: 0,
     title: 'SV Drochtersen/Assel',
     contentmodel: 'wikitext',
     pagelanguage: 'de',
     pagelanguagehtmlcode: 'de',
     pagelanguagedir: 'ltr',
     touched: '2017-10-09T14:48:39Z',
     lastrevid: 168662052,
     length: 8187,
     fullurl: 'https://de.wikipedia.org/wiki/SV_Drochtersen/Assel',
     editurl: 'https://de.wikipedia.org/w/index.php?title=SV_Drochtersen/Assel&action=edit',
     canonicalurl: 'https://de.wikipedia.org/wiki/SV_Drochtersen/Assel' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }
https://upload.wikimedia.org/wikipedia/commons/f/f8/Flag_of_Macedonia.svg
kper commented 6 years ago

Here are more, but this time I was on the english wikipedia

var test = 5747191;

wiki()
    .findById(test)
    .then(page => {
        console.log(page);
        page.mainImage().then((img) => {
            console.log(img);
        });
    });
{ raw: 
   { pageid: 5747191,
     ns: 0,
     title: 'Kosovo national football team',
     contentmodel: 'wikitext',
     pagelanguage: 'en',
     pagelanguagehtmlcode: 'en',
     pagelanguagedir: 'ltr',
     touched: '2017-10-17T17:36:26Z',
     lastrevid: 805591874,
     length: 44707,
     fullurl: 'https://en.wikipedia.org/wiki/Kosovo_national_football_team',
     editurl: 'https://en.wikipedia.org/w/index.php?title=Kosovo_national_football_team&action=edit',
     canonicalurl: 'https://en.wikipedia.org/wiki/Kosovo_national_football_team' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }
https://upload.wikimedia.org/wikipedia/commons/f/f3/Flag_of_Switzerland.svg
{ raw: 
   { pageid: 681862,
     ns: 0,
     title: 'Switzerland national football team',
     contentmodel: 'wikitext',
     pagelanguage: 'en',
     pagelanguagehtmlcode: 'en',
     pagelanguagedir: 'ltr',
     touched: '2017-10-17T20:17:26Z',
     lastrevid: 805814758,
     length: 44472,
     fullurl: 'https://en.wikipedia.org/wiki/Switzerland_national_football_team',
     editurl: 'https://en.wikipedia.org/w/index.php?title=Switzerland_national_football_team&action=edit',
     canonicalurl: 'https://en.wikipedia.org/wiki/Switzerland_national_football_team' },
  html: [Function: html],
  content: [Function: content],
  summary: [Function: summary],
  images: [Function: images],
  references: [Function: references],
  links: [Function: links],
  categories: [Function: categories],
  coordinates: [Function: coordinates],
  info: [Function: q],
  backlinks: [Function: backlinks],
  rawImages: [Function: h],
  mainImage: [Function: mainImage],
  langlinks: [Function: langlinks],
  rawInfo: [Function: p] }
https://upload.wikimedia.org/wikipedia/commons/4/49/Flag_of_Ukraine.svg