public static IEnumerable <string> GetAVFlvUrl(string AVnum, out IEnumerable <string> renames, List <BiliInterfaceInfo> binfos = null) //TODO: 试试元组
{
string[] avnp = Regex.Split(AVnum, "_|-|#");
string avnum = GetAVdenum(avnp[0]);
int page = 1;
if (avnp.Length > 1)
{
try
{
page = int.Parse(avnp[1]);
}
catch
{
Log.Warn(AVnum + " - 无法识别分P编号,将下载P1");
}
}
BiliInterfaceInfo info = null;
IEnumerable <string> flvs = null;
List <string> rrnames = new List <string>();
try
{
info = GetInfo(avnum);
if (page > 1)
{
if (info.pagesn.Count >= page)
{
flvs = GetFlvUrls(uint.Parse(info.pagesn[page - 1].cid));
}
else
{
Log.Warn(AVnum + $" - 目标视频仅有{info.pagesn.Count}P,将下载P1");
flvs = GetFlvUrls(info.cid);
}
}
else
{
flvs = GetFlvUrls(info.cid);
}
string topstring = "";
try
{
if (binfos != null)
{
int paiming = (from b in binfos where b.avnum == info.avnum select b.Fpaiming.Value).First();
if (paiming != 0 && paiming <= 20)
{
topstring = "TOP_" + paiming + "-";
}
}
} catch { }
info.title = $"{info.title}_{info.avnum}_P{page}_{info.pagesn[page - 1].part}";
info.title = TSDownload.removeInvChrInPath(info.title);
for (int i = 0; i < flvs.Count(); i++)
{
string filename = Path.GetFileName(new Uri(flvs.ElementAt(i)).AbsolutePath);
rrnames.Add($"{filename}$///${topstring}{info.title}_{i + 1}.flv");
}
}
catch (Exception e)
{
Log.Error("AV" + avnum + "的数据发生错误,请稍后重试!" + e.Message);
}
renames = rrnames;
return(flvs);
}