Skip to main content

A Python script for copying files referenced by m3u/m3u8/pls playlists

Project description

Introduction

copypl is a Python 3 script to copy the files referenced by a playlist (M3U, M3U8, or PLS) to a destination folder while retaining the folder structure of the original locations. By default, the playlist file is also copied; if the locations in the playlist are relative to the playlist, this means the copied playlist file will be correctly referencing the copied files.

Since this tool is intended for copying audio playlists, by default it will also copy JPEG and PNG files (cover art images, presumably) contained in the same folders that contain the files referenced by the playlist. An argument allows modification of additional file extensions to copy. Regardless of original intent, this tool should also work well with playlists containing video or other file types. However, for security and simplicity sake, it only works with local files contained within the folder containing the playlist file, or a subfolder.

A folder heirarchy is created in the destination folder relative to the playlist folder.

Usage

By default, copypl will copy the files referenced by a playlist, any JPEG and PNG files in referenced folders, and the playlist file itself to a destination folder:

copypl /share/Music/Favorites.m3u8 /mnt/sdcard

Or on Windows:

copypl C:\Music\Favorites.m3u8 D:\

The folders created at the destination mimic the folders relative to the source playlist file. For example, suppose the playlist in the first example above contained the following entries:

Popular/Releases/Heap, Imogen/Ellipse/113 - Half Life.ogg
/share/Music/Popular/Releases/Rush/2112/01 - 2112.ogg

Also suppose that the Ellipse and 2112 folders contained a cover.jpg file. The destination would like like so:

/mnt/sdcard/Favorites.m3u8
/mnt/sdcard/Popular/Releases/Heap, Imogen/Ellipse/113 - Half Life.ogg
/mnt/sdcard/Popular/Releases/Heap, Imogen/Ellipse/cover.jpg
/mnt/sdcard/Popular/Releases/Rush/2112/01 - 2112.ogg
/mnt/sdcard/Popular/Releases/Rush/2112/cover.jpg

The playlist file can be excluded from the copy using the --copy-playlist argument. Copy of related files can be controlled by the --extra-extension argument, but note that any argument passed will clear the defaults. Finally, by default, for efficiency, copypl will check modification timestamps of the source and destination files, and only overwrite older destination files. In addition, it will output a warning if an existing destination file is newer than the source file. Use the --ignore-mtime to always overwrite. Note that this may cause files to get copied multiple times, e.g., if the playlist references multiple files in a folder, then the extra files in the folder will get copied repeatedly.

Installation

Warning

Some Linux distributions discourage installation of system-level python packages using pip or setup.py install, due to collisions with the system package manager. In those cases, dependencies should be installed through the package manager, if possible, or choose a user folder installation method.

Installing with pip

If your system has pip installed, and you have access to install software in the system packages, then kantag kan be installed as administrator from PyPI:

# pip install copypl

If you do not have access to install system packages, or do not wish to install in the system location, it can be installed in a user folder:

$ pip install --user copypl

Installing from source

Either download a release tarball from the Releases page, and unpack:

$ tar zxvf copypl-1.0.0.tar.gz

Or get the latest source from the git repository:

$ git clone https://bitbucket.org/dgasaway/copypl

If you have access to install software in the system packages, then it can be installed as administrator:

# python setup.py install

If you do not have access to install system packages, or do not wish to install in the system location, it can be installed in a user folder:

$ python setup.py install --user

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copypl-1.0.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

copypl-1.0.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file copypl-1.0.1.tar.gz.

File metadata

  • Download URL: copypl-1.0.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9

File hashes

Hashes for copypl-1.0.1.tar.gz
Algorithm Hash digest
SHA256 82fe62e620990f8669ae22e67e9c6df6dd30ddb9f53de6b6b92a1cfec45d2263
MD5 02fae77a94345f2c784884b5c7edd3b3
BLAKE2b-256 c240864ef365795d193461fff0ea96bce84efc1736f7213d33aee2b0a885b998

See more details on using hashes here.

File details

Details for the file copypl-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: copypl-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9

File hashes

Hashes for copypl-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0509833ad18335c86e79087477e8f47b3cc49134d909a71d08454690cdc95967
MD5 6f4f528096f5bc6f493527ecd7aac637
BLAKE2b-256 68e33c5cbb0fc1a06095af0342497255ad499669c31367b2455cb576b99d93fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page