跳至主要内容

歌曲地址解析器 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 产品随想的博客

产品随想 | 陪读《乔布斯传》:1-17章

乔布斯经典照片集 坐在麗莎電腦旁。他說:「毕加索曾說:「好的藝術家懂得模仿,佛大的藝術家善於偷取。」因此,窃取偉大的點子沒有什麼好羞耻的。 與蓋茲在電話中達成協議:「比爾,謝謝你支持蘋果。因為你的支持,世界將變得更美好。」 1997年蘋果在波士頓舉行的麥金塔世界大會,蓋茲透過衛星連線在巨大的螢幕上出現。質伯斯說:「我真是笨死了,竟然讓蓋兹以這種方式現身。他讓我看起來好沙小。」 ──时刻自省 前言 The people who are crazy enough to think they can change the world are the ones who do. 只有那些瘋狂到以為自己可以改變世界的人, 才能改變這個世界。 這麼些年來,賈伯斯說起話來的認真與專注態度,著實打動不少人。我們一直保持連絡,即使在他被逐出蘋果之後,我們還有來往。每次他有新產品要推出時,像 NeXT 電腦或皮克斯 (Pixar)的電影,他就會來找我。他常帶我去曼哈頓下城一家壽司店用餐,講起他的產品,渾身散發出光和熱,眉飛色舞的說這是他登峰造極之作。我喜歡這個人。 ──对自己产品深深的爱 他的堅持教我疑惑。人人都知道賈伯斯不道餘力捍衛隱私, 而且我不知道他是否看過我寫的任何一本傳記。我還是不敢立刻答應,只說或許再等等。然而到了 2009年,我接到他太太蘿琳. 鮑威爾打來的電話。她直截了當說:「如果你還想為史帝夫寫傳,最好趕快動筆。」這是他第二次因病向公司請長假。我坦言他早在2004 年得知自己罹患胰臟癌的時候就曾主動邀我寫傳,但我當時對他罹癌的事一無所知。蘿琳解釋說,他們盡量保密,因此當時根本沒幾個人知道。他是在動手術的前夕打電話給我的。 ──和Make Something Wonderful对照起来看 他還說,自從他回到蘋果重新掌權,這十二年來是他創造新產品的高峰期,但他還有更重要的目標,也就是效法惠普的惠立和普克(David Packard),締造一家創新動力無限的公司,進而超越惠普。 ──苹果公司才是乔布斯最得意的产品 他說:「我一直認為,自己是個偏向人文的孩子,但我也喜歡電子的東西。後來,我讀到寶麗來(Polaroid)創辦人蘭德 (Edwin Land)曾說過,一個人能站在人文和科學的交會口,兼容贯通,才是真正的人才。在那當下,我决定要當這樣的人。」他似乎在暗示我,這可以做為傳...

产品随想 | 周刊 第85期:e-Residency与数字游民

  David Shambaugh   https://www.google.com/search?q=David+Shambaugh 中国问题研究专家,著作极多 郭玉闪   https://zh.wikipedia.org/wiki/郭玉闪?useskin=vector 中国公共知识分子 我只想好好观影   github.com/BetterWorld-Liuser/autoMovies 刘煜辉:中国资本市场灵魂出窍 最有活力的公司几乎不在A股   https://finance.sina.com.cn/stock/marketresearch/2017-06-23/doc-ifyhmtek7705574.shtml 回看17年的专家讲话,还是挺有水平的,挺多都认可 纽约文化沙龙   https://www.youtube.com/@user-cu2hl5tf6y/videos 视频质量出奇的高,推荐 透视中国政治by吴国光、程晓农 备忘下,貌似评价挺好的一本书 CAPI China Chair Wu Guoguang (吴国光 / 吳國光)   https://www.youtube.com/playlist?list=PLIt1szHhnm_Hso3jGUbfGpnEAbsPOuEVV 因为热爱中国,我们越要看懂中国 AI Canon   https://a16z.com/2023/05/25/ai-canon/ in this post, we’re sharing a curated list of resources we’ve relied on to get smarter about modern AI. We call it the “AI Canon” because these papers, blog posts, courses, and guides have had an outsized impact on the field over the past several years. 希望中国的投資機構,也能有更多的分享與輸出,提升整個社會的認知 Cantonese Font 粵語字體   https://visual-fonts.com/zh/...

Steve Jobs at 44, By Michael Krantz, 1999

Differences and Similarities Between Apple and Pixar Apple turns out many products--a dozen a year; if you count all the minor ones, probably a hundred. Pixar is striving to turn out one a year. But the converse of that is that Pixar's products will still be used fifty years from now, whereas I don't think you'll be using any product Apple brings to market this year fifty years from now. Pixar is making art for the ages. Kids will be watching Toy Story in the future. And Apple is much more of a constant race to continually improve things and stay ahead of the competition.  His Role At Pixar At Pixar my job is to help build the studio and recruit people and help create a situation where they can do the best work of their lives. And to some degree it's the same at Apple. But at Pixar, I don't direct the movies, whereas at Apple probably, if I had to pick a role out of a film production, I'd be the director. So it...

2018各行业应届生薪资不完全样本往期汇总-职场红领巾

文章来源自职场红领巾公众号2018.4.21日推送,在此表示感谢 产品岗 百度商业产品 14K*14 拼多多产品管培 12K*14 今日头条产品 16K*18 头条PM整个Package接近300K/年 美团产品Offer 14K*16 base上海 百度产品研究生 11.5K*14.6 base 上海 京东产品17K*13 百度产品 220K/年 网易 产品培训生 硕士 15K*18 SP base杭州 不知名互联网公司校招PM 12K*15 base北京 技术岗 微软 软件工程师 本科 260K/年 蚂蚁金服算法工程师 20K*16 拼多多开发本科400K/年 商汤科技本科技术岗 14K/月 税前 海康威视研究院 算法工程师 220K/年 微信算法岗 SP 360K/年 的package 今日头条 程序员 研究生 10K/月 base北京 滴滴程序员 16K*16 亚马逊 小四年经验 研发 50K/月 Facebook应届毕业生  软件开发工程师   打包 115k$/年(30%-40%税) base湾区 京东算法 普通Offer 234K/年 运营岗 滴滴北京运营岗 硕士 12K*15 奖金另算 网易游戏运营 150K/年 左右 网易运营 8K*13(奖金0~3个月) 网易新闻运营8K/月 腾讯游戏运营 本科6K/月 上海京东时尚本科8K/月 京东运营岗 11K/月 base北京亦庄总部 今日头条 渠道营销运营 6K/月(加房补) 网易考拉 活动运营 13K*16 OFO城市运营管培13K*14 爱范儿运营 8K/月 滴滴长三角某二线城市运营管培生 薪资 7.6K*13 +每个月40%绩效 货车帮 数据运营 12K/月 卡宾电商 管培 10K/月 含浮动绩效 曹操专车 运营管培生  加各种补贴税前5.4K/月  base杭州 京东金融海龟回来8K/月 北京蓝港互动...

巴菲特致股东信-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...

Interview with Steve Jobs, WGBH, 1990

Interviewer: what is it about this machine? Why is this machine so interesting? Why has it been so influential? Jobs: Ah ahm, I'll give you my point of view on it. I remember reading a magazine article a long time ago ah when I was ah twelve years ago maybe, in I think it was Scientific American . I'm not sure. And the article ahm proposed to measure the efficiency of locomotion for ah lots of species on planet earth to see which species was the most efficient at getting from point A to point B. Ah and they measured the kilocalories that each one expended. So ah they ranked them all and I remember that ahm...ah the Condor, Condor was the most efficient at [CLEARS THROAT] getting from point A to point B. And humankind, the crown of creation came in with a rather unimpressive showing about a third of the way down...

Steve Jobs: Rolling Stone’s 2003 Interview

  When Steve Jobs cruises into the airy reception area on the Apple Computer campus in Cupertino, California, on a recent morning, nobody pays much attention to him, even though he’s the company’s CEO. He’s wearing shorts, a black T-shirt and running shoes. Tall and a little gawky, Jobs has a fast, loping walk, like a wolf in a hurry. These days Jobs seems eager to distance himself from his barefoot youth – who was that crazy kid who once called the computer “a bicycle for the mind”? – and driven to prove himself as a clear-thinking Silicon Valley capitalist. Jobs punches the elevator button to the fourth floor, where his small office is located. For a man who is as responsible as anyone for the wonder and chaos of Silicon Valley, Jobs’ view of it all is surprisingly modest: shrubby treetops extending out toward San Francisco Bay, the distant whoosh of the freeway below. There is nothing modest, however, about Apple’s recent accomplishments. In the past few months,...

产品随想 | 周刊 第67期:静水铭室

Products Design Scenes #77   https://walling.app/TGE6qnCacxmwEV3d2lg2/design-scenes-77efbc88e4bbaeefbc89 非常不错的产品/设计周报 静水铭室   https://liuliu.me/ 静水可铭,丰山须镂。 - Silent Water and Curved Mountain 不错的中英博客 Classic HCI Demos   https://jackrusher.com/classic-ux/ A curated collection of HCI demo videos produced during the golden age from 1983-2002. 经典老演示Demo health-code-index   https://github.com/ilovexjp/health-code-index 健康码模拟 - 索引 EnergyStar   https://github.com/imbushuo/EnergyStar EnergyStar is a terrible* Windows application that leverages Windows EcoQoS API to throttle any inactive user process and background applications to improve system thermal and battery life, similar to the process management strategy on modern Apple macOS releases. 中共政治精英数据库   https://chinadatalab.ucsd.edu/elites/ Victor Shih/史宗瀚维护的一个履历库 Tribler   https://github.com/Tribler/tribler Privacy enhanced BitTorrent client with P2P content discovery 在美国执法区会有帮助 nuclear   https://github....

Steve Jobs: `There's Sanity Returning', 1998

Nobody can doubt the charisma of Steven P. Jobs. The interim CEO of Apple Computer Inc., who returned to the company last July after his ignominious 1985 ouster, has brought back his legendary vision, impatience, and infectious passion for the Macintosh. Jobs spoke to Business Week Correspondent Andy Reinhardt in Apple's stark, fourth-floor boardroom, just after the company rolled out its new software strategy on May 11. Note: This is an extended, online-only version of the Q&A that appears in the May 25, 1998, issue of Business Week. Q: Now that you've introduced the new, bold-looking iMac, are you going to do some radically different products? A: There's a lot of talk about such things -- about handhelds, set-top boxes. A lot of computer companies have been searching for a consumer product. My view is that the personal computer has been the most successful consumer product of the last 10 years. What we have to do, what the industry stopp...