Skip to content

Commit

Permalink
[BUGFIX] Fix missing title in kitsu
Browse files Browse the repository at this point in the history
  • Loading branch information
lolamtisch committed May 3, 2019
1 parent 00c0647 commit 5818080
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/provider/Kitsu/entryClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ export class entryClass{
if(this.getEpisode() === NaN) this.setEpisode(0);
this.setScore(this.getScore());

this.name = this.animeI().attributes.titles.en;
if(typeof this.name == 'undefined' || !this.name) this.name = this.animeI().attributes.titles.en_jp;
if(typeof this.name == 'undefined' || !this.name) this.name = this.animeI().attributes.titles.ja_jp;
this.name = helper.getTitle(this.animeI().attributes.titles);

this.totalEp = this.animeI().attributes.episodeCount? this.animeI().attributes.episodeCount: this.animeI().attributes.chapterCount;
if(this.totalEp == null) this.totalEp = 0;
Expand Down
14 changes: 14 additions & 0 deletions src/provider/Kitsu/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,17 @@ export async function userId(){
});
}
}

export function getTitle(titles){
var title = titles.en;
if(typeof title == 'undefined' || !title) title = titles.en_jp;
if(typeof title == 'undefined' || !title) title = titles.ja_jp;
if(typeof title == 'undefined' || !title){
var keys = Object.keys(titles);
if(!keys.length){
return 'No Title';
}
title = titles[keys[0]];
}
return title;
}
4 changes: 1 addition & 3 deletions src/provider/Kitsu/userList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ export function prepareData(data, listType): listElement[]{
var list = data.data[i];
var el = data.included[i];

var name = el.attributes.titles.en;
if(typeof name == 'undefined' || !name) name = el.attributes.titles.en_jp;
if(typeof name == 'undefined' || !name) name = el.attributes.titles.ja_jp;
var name = helper.getTitle(el.attributes.titles);

var malId = NaN;
for (var k = 0; k < data.included.length; k++) {
Expand Down

0 comments on commit 5818080

Please sign in to comment.