Skip to content

I just started on GitHub, eventually I plan to share my Python scripts to help you manage your iTunes music library

Notifications You must be signed in to change notification settings

jrsousa2/Python-scripts-for-iTunes-WMP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I just started on GitHub, eventually I plan to share my Python scripts to help you manage your iTunes music library.


11/03/2023 Edit: I've just shared four of the various python codes that I use to manage my music collection (with roughly 63,000 mp3 files) in both iTunes and Windows Media Player.


The main code Call_Save_to_Excel.py can be run from VS Code (or any other suitable python compiler/editor) and will create an Excel file with a list of your mp3 files and chosen tags, either through an interface with iTunes or Windows Media Player. You can choose to export a list of files (plus tags) either for all of your library or for a playlist (or set of playlists).


These are relatively basic codes and are useful to give first time users some insights into the libraries of functions, methods and properties of both the WMP and iTunes COM API's. (Asking ChatGPT to create this type of code doesn't work, it gets lots of these API questions wrong -- ChatGPT struggles with tricky questions.)


For example:
   How can you directly reference a track in the iTunes library with a tuple of 4 ID numbers?
   How do you read the file tags that WMP keeps in the metadata, some of which are embedded into the file and some of which are external?
   How can you sync play counts between iTunes and WMP? (Code Call_Sync_Plays.py does that by taking the max of both).


Here's a brief description of the parameters of the codes:


Code Call_Save_to_Excel.py calls Read_PL.py (module for iTunes) and WMP_Read_PL.py (module for WMP)

def Save_Excel(PL_name=None,PL_nbr=None,Do_lib=False,rows=None,iTunes=True):
iTunes: If True, will use iTunes library or playlists (if False, it will use WMP)
Do_lib: If True, will run on the whole library instead of a playlist (or list of playlists)
PL_name: If supplied and Do_lib=False, will create a list of files and tags for the playlist PL_name
PL_nbr: If supplied and Do_lib=False, will create a list of files and tags for the playlist number PL_nbr
rows: Whether the source is the whole library or a playlist, this option limits the number of files to read, if necessary.

If none of the above parameters (PL_name, PL_Nbr) is supplied, and Do_lib=False, the code will display a list of playlists along with their respective numbers (per the iTunes or WMP libraries), and the user will be able to enter all playlists that they wish to process separated by comma (the program has instruction prompts and other messages to guide the user).


col_names: This variable is entered straight into the code and identifies the tags that the user wants to extract from the mp3 files.
(The code can be easily modified to have this variable as a parameter to call the main macro with.)
Here's an example:
col_names = ["Arq","Art","Title","Year"]


Here's a list of all the tags that can be extracted: image


Be sure to change the default folder that the Excel file will be saved to in the main code.
This is done in lines 41 and 43 of the main codes and is currenty set to:
file_nm = "D:\iTunes\Excel\" + user_inp + ".xlsx"


Finally, this is a snapshot of one output file: image

About

I just started on GitHub, eventually I plan to share my Python scripts to help you manage your iTunes music library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages