添加 BiliTool 的 javadoc

This commit is contained in:
A.C.Sukazyo Eyre 2022-10-18 18:41:04 +08:00
parent 3ec69df9b8
commit 1cadb3b05f
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
2 changed files with 36 additions and 1 deletions

View File

@ -6,5 +6,5 @@ package cc.sukazyo.cono.morny;
public class GradleProjectConfigures { public class GradleProjectConfigures {
public static final String VERSION = "0.8.0.8"; public static final String VERSION = "0.8.0.8";
public static final String CODENAME = "putian"; public static final String CODENAME = "putian";
public static final long COMPILE_TIMESTAMP = 1666028272898L; public static final long COMPILE_TIMESTAMP = 1666081630449L;
} }

View File

@ -16,6 +16,23 @@ public class BiliTool {
private static final char[] BV_TEMPLATE = "1 4 1 7 ".toCharArray(); private static final char[] BV_TEMPLATE = "1 4 1 7 ".toCharArray();
private static final int[] BV_TEMPLATE_FILTER = new int[]{9, 8, 1, 6, 2, 4}; private static final int[] BV_TEMPLATE_FILTER = new int[]{9, 8, 1, 6, 2, 4};
/**
* Convert a <a href="https://www.bilibili.com/">Bilibili</a> AV video id format to BV id format.
* <p>
* the AV id is a number; the BV id is a special base58 number, it shows as String in programming.<br>
* eg:<br>
* while the link <i>{@code https://www.bilibili.com/video/BV17x411w7KC/}</i>
* shows the same with <i>{@code https://www.bilibili.com/video/av170001/}</i>,
* the AV id is <u>{@code 170001}</u>, the BV id is <u>{@code 17x411w7KC}</u>
* <p>
* for now , the BV id has 10 digits.
* the method <b>available while the <u>av-id < 2^27</u></b>, while it theoretically available when the av-id < 2^30.
*
* @see <a href="https://www.zhihu.com/question/381784377/answer/1099438784">mcfx的回复: 如何看待 2020 3 23 日哔哩哔哩将稿件的av 变更为BV </a>
*
* @param bv the BV id, a string in (a special) base58 number format, <b>without "BV" prefix</b>.
* @return the AV id corresponding to this bv id in <a href="https://www.bilibili.com/">Bilibili</a>, formatted as a number.
*/
@Nonnegative @Nonnegative
public static long toAv (@Nonnull String bv) { public static long toAv (@Nonnull String bv) {
long av = 0; long av = 0;
@ -25,6 +42,24 @@ public class BiliTool {
return (av-V_CONV_ADD)^V_CONV_XOR; return (av-V_CONV_ADD)^V_CONV_XOR;
} }
/**
* Convert a <a href="https://www.bilibili.com/">Bilibili</a> BV video id format to AV id format.
* <p>
* the AV id is a number; the BV id is a special base58 number, it shows as String in programming.<br>
* eg:<br>
* while the link <i>{@code https://www.bilibili.com/video/BV17x411w7KC/}</i>
* shows the same with <i>{@code https://www.bilibili.com/video/av170001/}</i>,
* the AV id is <u>{@code 170001}</u>, the BV id is <u>{@code 17x411w7KC}</u>
* <p>
* for now , the BV id has 10 digits.
* the method <b>available while the <u>av-id < 2^27</u></b>, while it theoretically available when the av-id < 2^30.
*
* @see <a href="https://www.zhihu.com/question/381784377/answer/1099438784">mcfx的回复: 如何看待 2020 3 23 日哔哩哔哩将稿件的av 变更为BV </a>
*
* @param av the (base10) AV id.
* @return the AV id corresponding to this bv id in <a href="https://www.bilibili.com/">Bilibili</a>,
* as a (special) base 58 number format <b>without "BV" prefix</b>.
*/
@Nonnull @Nonnull
public static String toBv (@Nonnegative long av) { public static String toBv (@Nonnegative long av) {
av = (av^V_CONV_XOR)+V_CONV_ADD; av = (av^V_CONV_XOR)+V_CONV_ADD;