网易云音乐云盘下架歌曲过滤 / 歌单对比 / JSON属性对比

网易云音乐的云盘上传了很多歌大概一千
过了很久发现有几个歌曲在云盘存在,但是歌单不见了
后面发现是歌下架了,不能加到歌单
于是想找出那些歌单是下架的

目前有两个想法,一是调api接口,分别获取自己的歌单和云盘的歌,然后操作集合拿差异集合
二是可以在以下路径找到Windows下的播放器的歌单文件,对比文件
文件是标准的json字符串记录播放列表:
%LOCALAPPDATA%\Netease\CloudMusic\webdata\file\queue

格式如下:
[
    {
        "track": {
            "name": "一点点"
        }
    },
    {
        "track": {
            "name": "golden hour"
        }
    }
]

对比效果:

json文件最好指定编码,支持交集差集,如果是对比歌名,默认值选track.name、差集就行

代码如下(找ai写了个对比集合的东西随便改了下):

#

# 选择两个json文件取json集合某个对象的某个属性,为两个set集合,输出交集

#

# 依赖 pip install pyinstaller

# 打包 pyinstaller -F -w json_comparator_gui.py -n JsonComparator

#           -F 打包成一个exe文件

#           -w 使用窗口,无控制台

#           -n 指定程序名称

#

import json

import tkinter as tk

from tkinter import filedialogmessagebox

def load_json(file_pathencoding):

    with open(file_path'r'encoding=encodingas json_file:

        return json.load(json_file)

def get_nested_property(objproperties):

    for prop in properties:

        obj = obj.get(prop)

        if obj is None:

            return None

    return obj

def compare_json_properties():

    file_path1 = filedialog.askopenfilename(title="Select the first JSON file")

    file_path2 = filedialog.askopenfilename(title="Select the second JSON file")

    encoding = encoding_entry.get()

    property_path = property_entry.get()

    try:

        json_data1 = load_json(file_path1encoding)

        json_data2 = load_json(file_path2encoding)

        property_names = property_path.split('.')

        values1 = set()

        for item in json_data1:

            nested_property = get_nested_property(itemproperty_names)

            if nested_property is not None:

                values1.add(nested_property)

        values2 = set()

        for item in json_data2:

            nested_property = get_nested_property(itemproperty_names)

            if nested_property is not None:

                values2.add(nested_property)

        diff = values1.symmetric_difference(values2)

        set转换为包含字符串的列表

        diff_list = [str(xfor x in diff]

        将列表转换为JSON字符串并保持中文输出指定4个缩进空格数

        diff_json_string = json.dumps(diff_listensure_ascii=Falseindent=4)

        result_text.delete(1.0tk.END)

        result_text.insert(tk.ENDdiff_json_string)

    except Exception as e:

        messagebox.showerror("Error"f"An error occurred: {str(e)}")

# Create the GUI

root = tk.Tk()

root.title("JSON Comparator by ssw")

window_width = 800

window_height = 500

screen_width = root.winfo_screenwidth()

screen_height = root.winfo_screenheight()

x_coordinate = int((screen_width - window_width) / 2)

y_coordinate = int((screen_height - window_height) / 2)

root.geometry(f"{window_width}x{window_height}+{x_coordinate}+{y_coordinate}")

encoding_label = tk.Label(roottext="Enter the file encoding (eg: utf-8):")

encoding_label.grid(row=0column=0sticky="w")

encoding_entry = tk.Entry(root)

encoding_entry.insert(tk.END'utf-8')  # Set default value

encoding_entry.grid(row=0column=1)

property_label = tk.Label(roottext="Enter the property path (eg: obj1.obj2.property):")

property_label.grid(row=1column=0sticky="w")

property_entry = tk.Entry(root)

property_entry.insert(tk.END'track.name')  # Set default value

property_entry.grid(row=1column=1)

compare_button = tk.Button(roottext="Select json file and compare"command=compare_json_propertiesbg="#90EE90")

compare_button.grid(row=2columnspan=3)

result_label = tk.Label(roottext="Differences:")

result_label.grid(row=3column=0sticky="w")

result_text = tk.Text(rootheight=30width=40)

result_text.grid(row=4column=0sticky="w")

info_label = tk.Label(roottext="Additional Info:")

info_label.grid(row=3column=1sticky="w")

info_text = tk.Text(rootheight=30width=70)

info_text.insert(tk.END''' 

选择两个json文件取json集合某个对象的某个属性,为两个set集合,输出交集\n

1.例如网易云音乐的播放列表json: 

%LOCALAPPDATA%\\Netease\\CloudMusic\\webdata\\file\\queue\n

2.json样例:

[

    {

        "track": {

            "name": "一点点"

        }

    },

    {

        "track": {

            "name": "golden hour"

        }

    }

]\n

3.取全部歌名到set集合的property path: 

track.name

''')

info_text.grid(row=4column=1sticky="e")

root.mainloop()

  • 21
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
阿里云盘是阿里巴巴集团旗下的一项云存储服务,网址是aliyundrive.com/s/byfea1wfunf。通过这个网址,用户可以访问阿里云盘的相关功能和服务。阿里云盘提供了高效、安全的文件存储和传输功能,用户可以将自己的文件上传至云端进行备份,随时随地、跨设备访问和共享这些文件。 使用阿里云盘,用户可以不必担心文件丢失或受损的问题。云端存储的文件可以进行自动同步,确保文件的实时备份。同时,阿里云盘采用了多层加密技术,保证文件安全。用户可以设置访问权限,灵活控制文件的分享范围,保护个人隐私。 此外,阿里云盘还提供了文件夹管理、文件的在线预览和编辑、多人协作等功能。用户可以创建文件夹进行分类整理,并进行文件的快速搜索。使用在线预览功能,可以直接浏览和编辑文档、音视频文件,无需下载到本地,提高办公和学习效率。多人协作功能方便用户与他人共享文件,并进行编辑、评论等操作。 阿里云盘还有丰富的移动端应用,用户可以随时随地通过手机或平板电脑访问文件。此外,通过与其他阿里巴巴生态系统的整合,阿里云盘还可以方便地与其他阿里系产品进行互联互通,提供更为便捷的工作和生活体验。 总而言之,阿里云盘作为一项可靠、安全的云存储服务,为用户提供了高效的文件管理和共享功能。通过访问aliyundrive.com/s/byfea1wfunf,用户可以开始使用阿里云盘,并享受其提供的各种便利和服务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值