Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdjiji committed Aug 22, 2022
1 parent e0a3d67 commit fc83e5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 10 additions & 6 deletions dist/templates/bgm-template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@
<div class="bangumi-meta">
<span class="bangumi-info-items" <%- color_meta %>>
<span class="bangumi-info-item" <%- color_meta %>>
<% if(item.eps){ %>
<% if(item.eps) { %>
<span class="bangumi-info-total"><%= item.eps %></span><em
class="bangumi-info-label-em">0</em>
class="bangumi-info-label-em">0</em>
</span>
<% } else { %>
<span class="bangumi-info-total">暂未播出</span><em
class="bangumi-info-label-em">0</em>
</span>
<% } %>
<span class="bangumi-info-item bangumi-type">
<span class="bangumi-info-label">类型</span> <em><%= item.type %></em>
</span>
<span class="bangumi-info-item bangumi-wish">
<span class="bangumi-info-label">想看</span> <em><%= item.collection.wish || '-' %></em>
<span class="bangumi-info-label">想看</span> <em><%= item.collection?.wish || '-' %></em>
</span>
<span class="bangumi-info-item bangumi-doing">
<span class="bangumi-info-label">在看</span> <em><%= item.collection.doing || '-' %></em>
<span class="bangumi-info-label">在看</span> <em><%= item.collection?.doing || '-' %></em>
</span>
<span class="bangumi-info-item bangumi-collect">
<span class="bangumi-info-label">已看</span> <em><%= item.collection.collect || '-' %></em>
<span class="bangumi-info-label">已看</span> <em><%= item.collection?.collect || '-' %></em>
</span>
<span class="bangumi-info-item bangumi-info-item-score">
<span class="bangumi-info-label">评分</span> <em><%= item.rating.score || '-' %></em>
<span class="bangumi-info-label">评分</span> <em><%= item.rating?.score || '-' %></em>
</span>
</span>
</div>
Expand Down
9 changes: 7 additions & 2 deletions src/lib/get-bgm-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getBangumiList = async (bgmtv_uid) => {
}
}
offset += LIMIT;
} while (offset * LIMIT < total);
} while (offset < total);
log.info(`Get bangumi list successfully, found ${total} bangumis`);
}

Expand All @@ -64,9 +64,14 @@ const getBangumi = async (bgm, cachePath) => {
const savedPath = path.join(cachePath, `/${bangumi_id}.json`);
if (await fs.exists(savedPath)) {
try {
return (await JSON.parse(await fs.readFile(savedPath)));
const read = await JSON.parse(await fs.readFile(savedPath));
if(read.id === bangumi_id) {
return read;
}
throw new Error(`Id not match when trying to load id=${bangumi_id}`);
} catch (error) {
// invalid bangumi
console.error(error);
return undefined;
}
}
Expand Down

0 comments on commit fc83e5e

Please sign in to comment.