跳至主要内容

歌曲地址解析器 yosong

项目开源地址:音乐消除国界,下载废除权限:歌曲地址解析器 yosong 感谢作者

那么,现在情况是这个样子的,我又想下歌了。在很久很久以前,百度音乐上的歌曲存有 128kbps、192kbps、320kbps 三种品质的,当时注册一个普通帐号就可以下载任意品质,在懒惰魔的诱惑下,我写了个叫 biabiamiamia 的程序,帮我下载指定歌手的全部歌曲
,那时候,喜欢的歌手基本都被拖到硬盘上了。最近,广播里放了几首新人的歌,邓紫棋版的“黑腹美”很是喜欢,好吧,把 biabiamiamia 翻出来看下还能跑不?我勒个去,完全用不起啊。是当个丑男还是当个懒人呢?好吧,一懒到底,必须得有个程序帮我批量下载。
现在的百度音乐存有普通品质(128kbps)、高品质(192kbps)、超高品质(320kbps)、无损品质(flac 800+kbps)四种,其中,320 的需要 VIP 帐号才能下载,而 flac 的甚至需要白金 VIP 才能下载,程序必须首先解决帐号权限的问题;另外,之前监管不那么严格的时候,百度音乐提供大量歌曲免费供大家下载,后来百度开始收费,那么相应百度自己需要先购买这些歌曲的版权,对于百度买了版权的歌曲,它当然可以通过收费会员机制盈利,但,未购买版权的歌曲,即便服务器上有现成的资源,也不得提供给会员下载,所以,程序还得解决这类因百度自身版权而无法下载的问题,比如,王菲-《醇经典》-誓言(http://music.baidu.com/song/s/75053f8340854da16d5 )。
耽误了我一周乒乓球时光,总算找到了可靠方法,剩下的就是编码实现 yosong,除了上述两个功能外,顺带实现了其它几项,基本上,现在的 yosong 具备了以下能力:
0)绕开白金收费会员才能下载无损品质歌曲的限制;
1)绕开百度自身版权问题歌曲而无法下载的限制(即便白金收费会员从官方渠道也无该功能);
2)绕开非大陆之外区域无法下载的限制(即便白金收费会员从官方渠道也无该功能);
3)一键式全站歌曲下载(即便白金收费会员从官方渠道也无该功能);
4)绕开高频访问出现验证码的限制。
虽然我用了"下载"这个词,但 yosong 并不会为你下载任何歌曲,严格地说,它是个百度歌曲最终下载地址解析工具,就我而言,我会先让 yosong 帮我解析出指定歌手的所有歌曲的 320 码率最终下载地址,然后以专辑为单位丢给迅雷帮我批量下载。
##源码安装
####‘linux’ 0)唯一依赖 libcurl,请自行安装;
1)代码采用 C++11 编写,gcc 版本不低于 4.7.1。
2)命令行下运行:
$ cd yosong/build/
$ cmake .
$ make && sudo make install
####‘osX’ 先将 build/CMakeLists.txt 中的
TARGET_LINK_LIBRARIES(yosong curl pthread)
替换成
TARGET_LINK_LIBRARIES(yosong curl pthread iconv)
其他同 linux 构建方法。
##命令行选项
yosong 是一个命令行程序,要用好它,你得先了解几个命令行选项的常识:
0)--option 'argc',其中,--option 称之为命令行选项,argc 为命令行参数;
1)某些命令行参数中可能含有对 shell 有特殊含义的字符(如,后台运行的 &、用于分割符的空格),为避免 shell 误解,通常,应该用英文单引号包裹命令行参数。如,--user 'yangyangwithgnu';
2)某些命令行选项可以有多个参数,通常,每个参数单独用英文单引号包裹,参数间用空格分割。如,--album '八度空间' '范特西' '我很忙';
yosong 典型的用法:
yosong --user 'yangyangwithgnu' --password 'abcd1234' --artist '伍佰'
这样,yosong 就会帮你把歌手伍佰的所有歌曲的 320 码率下载地址解析出来,一是输出在屏幕上、一是保存至 ~/伍佰@HHMMSS.txt 中。
具体而言,yosong 提供了如下命令行选项。
--help
显示帮助信息。该选项优先级最高,出现该选项时忽略其他所有选项。
可选。
--version
显示当前版本信息。该选项优先级仅次 --help
可选。
--user
指定百度帐号。普通免费帐号即可,无需白金付费会员帐号。
必填。
单参数。
无默认值。
--password
指定百度帐号密码。
必填。
单参数。
无默认值。
--artist
指定歌手名。
必填。
单参数。
无默认值。
--album
指定专辑名。该专辑必须归属 --artist 指定歌手的,否则无法下载。若未指定该选项则默认下载 --artist 指定的歌手的所有专辑、所有歌曲。若有多张专辑,请空格隔开,如,--album '八度空间' '范特西' '我很忙'。
可选。
多参数。
无默认值。
--quality
指定歌曲品质。百毒音乐上的歌曲有四种品质:标准品质(128kbps)、高品质(192kbps)、超高品质(320kbps)、无损品质(800+kbps),yosong 依次有四种参数与之对应:128、192、320、flac。如果指定品质不存在,那么依次找 320、192、128、flac 等存在的品质,找到即下。
必填。
单参数。
默认值,320。
--ignore-size-lower
有些歌曲尺寸太小相应音质就不高,若想忽略小尺寸的歌曲,可以通过该选项指定一个以 MB 为单位的尺寸下限,凡低于该尺寸的歌曲均不下载。注意,0)该选项的参数可以指定小数;1)指定时不用带单位,如,--ignore-size-lower 6 而非 --ignore-size-lower 6M;2)如果不在乎歌曲尺寸可以将该选项指定为 0。
必填。
单参数。
默认值,6。
--path
指定歌曲最终下载地址保存路径,文件命名规则:artistname@hhmmss.txt
必填。
单参数。
默认值,~/
##FQA
Q0:yosong 可以解析哪些歌手的歌曲?
A0http://music.baidu.com/artist
Q1:为何我昨天解析出的最终下载地址,今天下载全部失败呢?
A1:最终下载地址是有有效期的,要下载时才解析,不要先解析一大堆等多久才下载,很可能过期滴。
Q2:yosong 为何不集成下载工具?
A2:我是个受尽 K.I.S.S. 摧残的人儿,术有专攻,让其他第三方专业下载工具去执行具体下载任务吧。当然,我也是个有爱的人儿,帮你准备了
bool Song::download (const string& path, const string& quality, const unsigned timeout);
成员函数,它内部集成 aria2c,适当调整下 main.cpp 中的逻辑即可集成下载。我倒是建议直接用迅雷,以专辑为单位把整个专辑的下载地址拷贝下来,迅雷自动除去非 URL 文本,批量下载,并且还能正确给文件命名。
Q3:为何有类似“咖哩鱼蛋(1.1MB too small)”红色报错信息?
A3:有些歌曲尺寸太小相应音质就不高,对于您这样有品味的人,宁可不下载也不要被这些低质声音污染耳朵,所以,你可以通过该选项指定一个以 MB 为单位的尺寸下限,告诉 yosong 忽略小于该尺寸的歌曲。如果你是个接受度很广的人,可以将 --ignore-size-lower 设置为 0。
Q4:为何默认品质是 320 而不是无损的 flac?
A4:尼玛,劳资的车载音响不支持 flac 格式 (ง •̀_•́)ง
Q5:为何迅雷下载回来的歌曲出现类似 96892368400320.mp3 这样的文件名?
A5:yosong 解析出来的最终下载地址类似 http://yinyueshiting.baidu.com/data2/music/51503996/96892368400320.mp3?xcode=0518d0d4beb3be2fea45adb97777a278d990c3a07c5eb44d ,通常来说,下载工具会向资源提供服务端查询文件名,然后再下载,迅雷在这方面做得不错,但如果你向单个资源服务器同时发起大量并行查询,其中某几个可能查询失败,所以就出现迅雷按 URL 中的信息给文件命名的情况。要规避这种情况,你可以减少并行下载任务数量(4 个为宜),或者,对已经下载的文件,右键查看音频属性,那儿会有正确的歌曲名,如下图:

(音频属性中提取真实文件名)
Q6:周杰伦的歌明显不全嘛?
A6:对于百度未收录的歌曲资源,yosong 无能为力。
Q7:yosong 要求输入百毒帐号,安不安全?
A7:不安全。我可能把持不住用你的帐号干各种邪恶、抑郁以及不纯洁的事。为了您一身的英明,建议你注册个小号,明白我的意思了么,亲爱的。
Q8:yosong 是否具备“一键”解析百毒音乐全站歌曲的能力?
A8:哼哼哼,好像、或许、应该、我觉得,是具备的。你知道,只需指定歌手名,yosong 能解析该歌手的所有专辑的所有歌曲,同时,yosong 又能遍历出所有歌手,所以,只需增加八行代码即可,具体是 ...,等下,我接个电话先,010-65232656 打来的 ...
Q9:我指定下载 flac 这种无损品质,为何 yosong 下载回来的是 mp3 格式呢?
A9:百毒音乐上的歌曲含有标准品质(128kbps)、高品质(192kbps)、超高品质(320kbps)、无损品质(800+kbps)等四种品质,前三者为 mp3 格式、最后一种为 flac 格式。大部分歌曲四种品质都有,少部分歌曲缺失某类品质,如果指定品质不存在,那么 yosong 依次查找 320、192、128、flac 等存在的品质,找到即下,所以,如果你指定的是 flac 而下载回来的是 mp3,那肯定是该歌曲缺失 flac 品质。至于说,在指定品质不存在时,查找优先级为何把 flac 排在最后,前面说过了,那是因为劳资的车载音响不支持 flac 格式,基本上,我只下载 320 品质的 mp3,如果某歌曲没有 320 的,我希望下载 192 的,而不是“自作聪明”下 flac 的。
Q10:yosong 最小只能以专辑为单位下载,如果我只想下载单首歌曲,咋办啊?
A10:请在门外帮我把门关上。
Q11:非正常退出 yosong 有无危害?
A11:yosong 通过某些机制绕开百度限制,其中涉及把歌曲加入收藏,收藏夹有收藏歌曲数量的限制(8K),虽然 yosong 会自动清理由它加入收藏的歌曲,但,当非正常退出时,清理这步可能未执行,所以,建议定期到 http://yinyueyun.baidu.com/ 手工清理收藏夹,否则,yosong 无法正常运行。
##接下来你可以
yosong 不是终点,而是你的起点,基于它你可以:
0)调用 Song::download() 集成 aria2c 下载工具;
1)创建 GUI 版本,为害怕 CLI 的亲们带去曙光;
2)创建网站版本,yosong 在幕后,提供歌曲下载地址解析,类似硕鼠网;
3)移植 windows 版本。
##最后的一定是最不重要的

Popular posts from 产品随想的博客

Interview at the All Things Digital D5 Conference, Steve and Bill Gates spoke with journalists Kara Swisher and Walt Mossberg onstage in May 2007.

Kara Swisher: The first question I was interested in asking is what you think each has contributed to the computer and technology industry— starting with you, Steve, for Bill, and vice versa. Steve Jobs: Well, Bill built the first software company in the industry. And I think he built the first software company before anybody really in our industry knew what a software company was, except for these guys. And that was huge. That was really huge. And the business model that they ended up pursuing turned out to be the one that worked really well for the industry. I think the biggest thing was, Bill was really focused on software before almost anybody else had a clue that it was really the software that— KS: Was important? SJ: That’s what I see. I mean, a lot of other things you could say, but that’s the high-order bit. And I think building a company’s really hard, and it requires your greatest persuasive abilities to hire the best ...

产品随想 | 周刊 第69期:Do not go gentle into that good night

Products Windows Apps That Amaze Us   https://amazing-apps.gitbook.io/windows-apps-that-amaze-us/ 令人精细的Windows App 文物出版社   https://book.douban.com/press/2456/ 这是一个宝藏出版社,出品书籍质量非常高,大开眼界 blind   https://www.teamblind.com/ 老外的匿名职场社交工具,挺有意思,看看硅谷的meme 中国科学技术大学测速网站   https://test.ustc.edu.cn/ 看着还不错,挺靠谱的 底层代码是LibreSpeed   https://github.com/librespeed/speedtest 能不能好好说话?   https://github.com/itorr/nbnhhsh 也是我的一个痛点 Tree Style Tab (aka TST)   https://github.com/piroor/treestyletab 一个超强的浏览器扩展插件,树状呈现浏览器标签 Failory Pitch Decks   https://www.failory.com/pitch-deck 超级多的融资计划投资板,Pitch Book AutoCut   https://github.com/mli/autocut 用文本编辑器剪视频 全网漫游指南   https://tagly.notion.site/tagly/a333efd8c3e54e12b123acd541e8d3e6 数字时代的指引,希望他们成功 IT eBooks   https://it-ebooks.info/ IT书籍下载 ToastFish   https://github.com/Uahh/ToastFish 一个利用摸鱼时间背单词的软件。 利用Win10通知栏,出现、背单词 Ideas 沈向洋:IDEA 如何找到创新的「甜区」   https://mp.weixin.qq.com/s/OlI5VUxQKU_ijWZClQCG0Q AIGC How Did Nor...

Foobar2000 组件安装教程

 原作者 博客地址   汉化作者 Asion博客   关于foobar 2000的一些资源 前言 foobar2000 由于其软件架构特点以及开放的姿态,使得第三方很容易开发组件(component)来拓展它的功能。由于在官网下载的默认安装文件只带了少量几个默认的组件,满足不了使用的需求,例如:默认不带 ape,tta,tak 等音频文件格式的解码器,很多无损压缩格式音乐没法播放。所以自己下载安装组件是必备的基本技能。 foobar2000 的中文汉化版(Asion 汉化)为了方便使用,集成了无损压缩文件解码器以及一些其它有用的插件,安装时选上即可,不喜欢折腾的建议使用汉化版。 这里组件指的是 foobar2000 标准组件(*.dll 文件),而非 vst 插件等其它插件,姑且把组件分为两类: 官方组件: 英文版安装包自带,安装时可选择; 第三方组件:非官方自带的组件 除了 foo_input_std.dll 和 foo_ui_std.dll 这两个组件是必须的外,其它的所有组件都 非必需 的,可以随需要增删。第三方组件可以去 官网 、 官方论坛 或者 官方 wiki 去找,也可以去贴吧等地逛逛。 下载 还是要强调一下,这里说的是 foobar2000 component ,不是中文网上通常说的 vst 插件。 下载好的组件包一般是 xxx.zip 或 xxx.fb2k-component 格式的文件,也有用 7z 打包的。前两种都是 zip 压缩(只要把 fb2k-component 改成 zip 文件就变成了 zip: 包)。标准状况下压缩包里的内容结构应该是 xxx.zip yyy.dll README.txt (可能没有) LICENCE.txt (可能没有) (其它杂七杂八) 除少数外一般只有一个 xxx.dll 文件.一定要注意压缩包结构不能是: xxx.zip yy folder (文件夹) zzz.dll … 否则要解压缩,提取那个 dll 文件。 安装 方法一(推荐) 打开 foobar2000 的菜单 文件 > 首选项(file >preferences) 的 组件(components...

UNstudio实习经验分享

再过一周,我就将离开UNstudio阿姆斯特丹总部,到其上海分部了,鉴于上海分部目前还不承担设计任务,因此可以视为我UNstudio参与设计的体验即将告一段落。这个实习,原定3个月,后来被要求延长到了6个月,后来又延长到9个月,现在看来最终大概有11个月——那天一问,发现我的合同已经到了9月份了,赶紧声明不能这么长,我8月得回学校了。

产品随想 | 周刊 第43期:历史上的今天

Products Huberman Lab   https://hubermanlab.com/ 一款聚焦于健康的播客 今日热榜   https://tophub.today/ 聚合展示,国内各热门榜单,对跟进热点非常有帮助,热点运营的好帮手 SketchyBar   https://github.com/FelixKratz/SketchyBar A highly customizable macOS status bar replacement Mac菜单栏定制 自定义程度很高,看作者展示的案例,暂时没想出这样的好处(不过应用本身的编辑,确实也没啥意义)生命在于折腾吧! Thanks-Mirror   https://github.com/eryajf/Thanks-Mirror 整理记录各个包管理器,系统镜像,以及常用软件的好用镜像,Thanks Mirror。 Musicn   https://github.com/zonemeen/musicn 一个下载高品质音乐的命令行工具,音乐来源: 咪咕 Planet Minecraft A creative Minecraft community fansite sharing maps, minecraft skins, resource packs, servers, mods, and more. 里面有很多动人的故事 可能是世界上最大的Minecraft社区,从2010年至今 The Uncensored Library   https://www.uncensoredlibrary.com/en blockworks   https://www.blockworks.uk/ "Distinctive maps for Minecraft that have educated players and risen to the level of art" 游戏也可以让人有更高的实现,而不仅仅是沉迷其中,国外游戏厂商比我们做的好太多 Minecraft_Memory_Bypass_GUI   https://github.com/xingchuanzhen/Minecraft_Memory_Bypass_GUI 绕过Minecraft...

巴菲特致股东信-1976年

 笔记: 为什么选择轻资产行业:当竞争疯狂时,不会强迫加入降价大战 最终选择了费雪的思想,选择能理解的优秀企业,以合理的价格买入并长期拥有 翻译: 雪球:https://xueqiu.com/6217262310/131440258 备份:https://archive.ph/XLK0S 原文: To the Stockholders of Berkshire Hathaway Inc, After two dismal years, operating results in 1976 improved significantly. Last year we said the degree of progress in insurance underwriting would determine whether our gain in earnings would be "moderate" or "major." As it turned out, earnings exceeded even the high end of our expectations. In large part, this was due to the outstanding efforts of Phil Liesche's managerial group at National Indemnity Company. In dollar terms, operating earnings came to $16,073,000, or $16.47 per share. While this is a record figure, we consider return on shareholders' equity to be a much more significant yardstick of economic performance. Here our result was 17.3%, moderately above our long-term average and even further above the average o...

巴菲特致股东信-1974年

 笔记: 价格战企业的逻辑:需要降价获取销量--->需要降低成本--->怎么降?扩大规模以摊低成本--->提高固定资产投入--->净资产回报率会降低 翻译: 雪球:https://xueqiu.com/6217262310/131257947 备份:https://archive.ph/5CEP6 原文: To the Stockholders of Berkshire Hathaway Inc.: Operating results for 1974 overall were unsatisfactory due to the poor performance of our insurance business. In last year's annual report some decline in profitability was predicted but the extent of this decline, which accelerated during the year, was a surprise. Operating earnings for 1974 were $8,383,576, or $8.56 per share, for a return on beginning shareholders' equity of 10.3%. This is the lowest return on equity realized since 1970. Our textile division and our bank both performed very well, turning in improved results against the already good figures of 1973. However, insurance underwriting, which has been mentioned in the last several annual reports as running at levels of unsustainable profitability, turned dramatically worse...

巴菲特致股东信-1973年

 笔记: 在上一年度预测的今年竞争加剧导致利润下滑,真的发生了 翻译Link: 雪球:https://xueqiu.com/6217262310/131257618 备份:https://archive.ph/KIfdT 原文: To the Stockholders of Berkshire Hathaway Inc.: Our financial results for 1973 were satisfactory, with operating earnings of $11,930,592, producing a return of 17.4% on beginning stockholders' equity. Although operating earnings improved from $11.43 to $12.18 per share, earnings on equity decreased from the 19.8% of 1972. This decline occurred because the gain in earnings was not commensurate with the increase in shareholders' investment. We had forecast in last year's report that such a decline was likely. Unfortunately, our forecast proved to be correct. Our textile, banking, and most insurance operations had good years, but certain segments of the insurance business turned in poor results. Overall, our insurance business continues to be a most attractive area in which to employ capital. Management'...

Commencement Address at Stanford University--“Stay hungry. Stay foolish.”

I am honored to be with you today for your commencement from one of the finest universities in the world. Truth be told— I never graduated from college. This is the closest I’ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That’s it. No big deal. Just three stories. The first story is about connecting the dots. I dropped out of Reed College after the first six months but then stayed around as a drop-in for another eighteen months or so before I really quit. So why did I drop out? It started before I was born. My biological mother was a young, unwed graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting...

巴菲特致股东信-1975年

 笔记: 华盛顿邮报已成为伯克希尔第一重仓股 翻译: 雪球:https://xueqiu.com/6217262310/131409324 备份:https://archive.ph/4hgK3 原文: To the Stockholders of Berkshire Hathaway Inc.: Last year, when discussing the prospects for 1975, we stated “the outlook for 1975 is not encouraging.” This forecast proved to be distressingly accurate. Our operating earnings for 1975 were $6,713,592, or $6.85 per share, producing a return on beginning shareholders ’ equity of 7.6%. This is the lowest return on equity experienced since 1967. Furthermore, as explained later in this letter, a large segment of these earnings resulted from Federal income tax refunds which will not be available to assist performance in 1976. On balance, however, current trends indicate a somewhat brighter 1976. Operations and prospects will be discussed in greater detail below, under specific industry titles. Our expectation is that significantly better results in textiles, earnings added from recent acquisitio...