Skip to content

Commit

Permalink
fix #26: correctly calculate cover frame size
Browse files Browse the repository at this point in the history
Signed-off-by: 鲁树人 <[email protected]>
  • Loading branch information
um-lsr committed Sep 12, 2024
1 parent 36e6801 commit 2b52a36
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ncmcrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,14 @@ NeteaseCrypt::NeteaseCrypt(std::string const &path)
mMetaData = new NeteaseMusicMetadata(cJSON_Parse(modifyDecryptData.c_str()));
}

// skip crc32 & unuse charset
if (!mFile.seekg(9, mFile.cur))
// skip crc32 & image version
if (!mFile.seekg(5, mFile.cur))
{
throw std::invalid_argument("can't seek file");
}

uint32_t cover_frame_len{0};
read(reinterpret_cast<char *>(&cover_frame_len), 4);
read(reinterpret_cast<char *>(&n), sizeof(n));

if (n > 0)
Expand All @@ -410,4 +412,5 @@ NeteaseCrypt::NeteaseCrypt(std::string const &path)
{
std::cout << "[Warn] " << path << " missing album can't fix album image!" << std::endl;
}
mFile.seekg(cover_frame_len - n, mFile.cur);
}

0 comments on commit 2b52a36

Please sign in to comment.