将 m3u8 文件转换为 wpl 文件

问题描述 投票:0回答:1

我使用 Windows Media Player 来管理计算机上的播放列表和音乐。但是,我想在我的 Android 设备上保留播放列表。就此而言,我有一个媒体播放器应用程序。该应用程序可以读取 wpl 文件,但在提取播放列表时将输出 m3u8 文件。这种格式无法被 Windows Media Player 读取,所以我必须将 m3u8 播放列表转换为 wpl 文件,以便在我的 Android 手机上进行的更改镜像到我的电脑。

除了那些可以赚钱的服务之外,我没有找到任何在线转换服务,但我不想使用这些服务。

android windows m3u8 wpl
1个回答
0
投票

我写了一个Python脚本,它将把播放列表文件转换成我想分享的wpl格式,以防万一有人遇到同样的问题

import os

import glob

script_folder = os.path.dirname(os.path.realpath(__file__))
playlists_folder = script_folder.replace("\\\\", "/").replace("\\", "/") + "/../Playlists/"
playlists_file_pattern = "*.m3u8"
glob_pattern = playlists_folder + playlists_file_pattern
playlist_file_paths = glob.glob(glob_pattern, recursive=True)
for playlist_file_path in playlist_file_paths:
    with open(playlist_file_path) as playlist_file:
        try:
            lines = [line.rstrip() for line in playlist_file]
            output_lines = "<?wpl version=\"1.0\"?>\n<smil>\n    <head>    </head>\n    <body>\n        <seq>"
            for line in lines:
                if "#EXT-X-RATING:" in line:
                    continue
                if "#EXTM3U" in line:
                    continue
                replaced = line.replace("path/to/Music","<media src=\"..") + "\"/>"
                output_lines = output_lines + "\n" + replaced
            output_lines = output_lines + "        </seq>\n    </body>\n</smil>"
            new_file_path = playlist_file_path.replace("M3u8Playlists", "wplPlaylists").replace("m3u8", "wpl").replace("wpl.wpl", "wpl")
            with open(new_file_path, "w") as output_file:
                 output_file.write(output_lines)
        except Exception as e:
            print(f"ERROR: File: '{playlist_file_path}'")
            print(e)

© www.soinside.com 2019 - 2024. All rights reserved.