吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 12256|回复: 81
收起左侧

[原创工具] 【C#】某DJ音乐网MP4文件下载器

  [复制链接]
Pojie1999.0909 发表于 2021-2-20 17:08
本帖最后由 Pojie1999.0909 于 2021-2-20 21:28 编辑

管理你好,如有违规,还请见谅!

vs2019编写的c# winform应用程序,.net framework 4.7 框架,引用了selenium和hzh_control动态库,前者用于模拟浏览器操作,后者用于UI

虽说用户体验不太好,但可以用它来批量下载音乐(一次最多下载30首,根据当前html页table标签有多少行决定)...

使用方法:
0.查看自己的edge浏览器版本,如下:
image.png
1.下载edge浏览器对应版本的WebDriver,网址:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads
2.将下载好的WebDriver放到目录 C:\WebDriver\bin 下面并添加到Path环境变量,将文件名修改为 MicrosoftWebDriver.exe,如下:

2

2

3.打开程序,输入网页地址,点击搜索,选中要下载的歌曲,点击下载,自动保存到 D:\ 盘根目录下

百度网盘:
复制这段内容后打开百度网盘App,操作更方便哦。 链接:https://pan.baidu.com/s/1affxLIHk36O13jwTTpe97w 提取码:p1f0--来自百度网盘超级会员V5的分享

求大佬们不要吝啬你们的【热心值】!求点赞、投币!我想升升级,多谢!


截图:

1

1



=====================================================
C# 程序很好反编译,感兴趣的朋友可以下载来看看,建议没有必要看,很简单,大佬请忽略...

以下是全部代码:
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HZH_Controls.Forms;
using HZH_Controls.Controls;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using System.IO;
using System.Net;
using System.Threading;

namespace BabyMusicDownloader
{
    public partial class Form1 : FrmWithTitle
    {
        public Form1()
        {
            InitializeComponent();
            m_SyncContext = SynchronizationContext.Current;
            this.Title = "【吾爱破解论坛】 BabyMusicDownloadApp - by Pojie1999.0909";
            this.IsShowCloseBtn = true;

            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Title", HeadText = "标题", Width = 40, WidthType = SizeType.Percent });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Href", HeadText = "链接", Width = 40, WidthType = SizeType.Percent });
            lstCulumns.Add(new DataGridViewColumnEntity()
            {
                DataField = "State",
                HeadText = "状态",
                Width = 20,
                WidthType = SizeType.Percent,
                Format = (a) => { return Convert.ToInt32(a) == 0 ? "等待下载" : Convert.ToInt32(a) == 1 ? "下载完成" : "歌曲已存在"; }
            });
            this.ucDataGridView1.Columns = lstCulumns;
            this.ucDataGridView1.IsShowCheckBox = true;
        }

        private void ucBtnExt1_BtnClick(object sender, EventArgs e)
        {
            lstSource.Clear();
            driver.Navigate().GoToUrl(ucTextBoxEx1.InputText);
            IWebElement table = driver.FindElement(By.ClassName("list_musiclist"));
            IList<IWebElement> redlines = table.FindElements(By.ClassName("redline"));
            foreach (IWebElement item in redlines)
            {
                string song = item.FindElement(By.TagName("a")).Text;
                lstSource.Add(new SongObj { Title = song + ".mp4", Href = item.FindElement(By.TagName("a")).GetAttribute("href"), State = "0" });
            }
            ucDataGridView1.DataSource = lstSource;
        }

        private void ucBtnExt2_BtnClick(object sender, EventArgs e)
        {
            Task.Run(() =>
            {
                ThreadProcSafePost();
            });
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            driver.Close();
            driver.Quit();
        }

        private void ThreadProcSafePost()
        {
            if (ucDataGridView1.SelectRows.Count < 1)
            {
                FrmDialog.ShowDialog(this, "请选择至少一条记录!", "提示");
            }
            else
            {
                foreach (var item in ucDataGridView1.SelectRows)
                {
                    string title = ((SongObj)item.DataSource).Title;
                    string href = ((SongObj)item.DataSource).Href;
                    driver.Navigate().GoToUrl(href);
                    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                    string truthUrl = js.ExecuteScript("return playurl2").ToString();
                    string fileName = rootPath + title;
                    if (!File.Exists(fileName))
                    {
                        WebClient client = new WebClient();
                        client.DownloadFile(truthUrl, fileName);
                        lstSource.Where(x => x.Title == title && x.Href == href).ToList()[0].State = "1";
                    }
                    else
                    {
                        lstSource.Where(x => x.Title == title && x.Href == href).ToList()[0].State = "2";
                    }
                    m_SyncContext.Post(SetDataGridViewSafePost, null);
                }
            }
        }

        private void SetDataGridViewSafePost(object state)
        {
            this.ucDataGridView1.ReloadSource();
        }

        IWebDriver driver = new EdgeDriver();
        const string domain = "http://www.bbdj.com/";
        const string rootPath = @"D:\";
        List<SongObj> lstSource = new List<SongObj>();
        SynchronizationContext m_SyncContext = null;

    }

    public class SongObj
    {
        public string Title { get; set; }
        public string Href { get; set; }
        public string State { get; set; }
    }
}


免费评分

参与人数 8吾爱币 +13 热心值 +7 收起 理由
金色枫叶 + 1 + 1 谢谢@Thanks!
bzhongliang + 1 用心讨论,共获提升!
xtayspwk + 1 + 1 我很赞同!
1946091139 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
紫色深瞳 + 1 + 1 谢谢@Thanks!
风之暇想 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
3yu3 + 1 + 1 谢谢@Thanks!
liufulin2002 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

lovecp 发表于 2021-3-31 22:23
1.下载edge浏览器对应版本的WebDriver,网址:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads
2.将下载好的WebDriver放到目录 C:\WebDriver\bin 下面并添加到Path环境变量,将文件名修改为 MicrosoftWebDriver.exe,

大佬,这一步真的不知道怎么操作,晕了唉
lanxiamantou 发表于 2021-2-23 11:20
zys材料人 发表于 2021-2-20 17:20
liufulin2002 发表于 2021-2-20 17:24
不懂编程,就看大佬们的工具了,谢谢分享!
simoney 发表于 2021-2-20 17:44
IE浏览器怎么办?
tys3610 发表于 2021-2-20 18:11
可以下载其他DJ网站的文件吗
sghzlx 发表于 2021-2-20 19:19
好                                                              .
 楼主| Pojie1999.0909 发表于 2021-2-20 21:30
本帖最后由 Pojie1999.0909 于 2021-2-20 21:32 编辑

@风之遐想 大佬,已修改网盘分享为永久有效,辛苦!@风之暇想@风之暇想 也不知道这个@成功了没有,手机上看不出来
 楼主| Pojie1999.0909 发表于 2021-2-20 21:32
Pojie1999.0909 发表于 2021-2-20 21:30
@风之遐想 大佬,已修改网盘分享为永久有效,辛苦!@风之暇想@风之暇想 也不知道这个@成功了没有 ...

@风之暇想
 楼主| Pojie1999.0909 发表于 2021-2-20 21:33
tys3610 发表于 2021-2-20 18:11
可以下载其他DJ网站的文件吗

不可以,只支持软件搜索框里的那个网站
 楼主| Pojie1999.0909 发表于 2021-2-20 21:35
simoney 发表于 2021-2-20 17:44
IE浏览器怎么办?

只支持edge哦,我觉得edge挺好用的
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 提醒:禁止复制他人回复等『恶意灌水』行为,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-27 02:35

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表