cjcodeproj / medialibrary

Python code to read XML media files
MIT License
2 stars 0 forks source link

TitleMunger could provide directory path information #149

Closed cjcodeproj closed 10 months ago

cjcodeproj commented 10 months ago

The TitleMunger class manipulates title strings to provide alternate representations of the data.

Film Title Sort Title Unique ID Title Catalog Title
V. I. Warshawski vi_warshawski vi_warshawski-1991-1 V.I. Warshawski (1991)
The Whole Nine Yards whole_nineyards+the whole_nineyards+the-2000-1 The Whole Nine Yards (2000)
3:10 To Yuma three_ten_to_yuma three_ten_to_yuma-1957-1 3:10 To Yuma (1957)

One variant that was created (but not documented) was a filename suitable string, which would be suitable if the data needed to be written out into a file.

Film Title Sort Title Unique ID Title Catalog Title Filename
V. I. Warshawski vi_warshawski vi_warshawski-1991-1 V.I. Warshawski (1991) v_i_warshawski
The Whole Nine Yards whole_nineyards+the whole_nineyards+the-2000-1 The Whole Nine Yards (2000) the_whole_nine_yards
3:10 To Yuma three_ten_to_yuma three_ten_to_yuma-1957-1 3:10 To Yuma (1957) 310_to_yuma

If an operation generates a large number of files (one file per content title), it would be beneficial to have a tree structure to prevent a single directory having all of the files. For building repositories, we already recommend a tree structure based on the title, so we could add a method to TitleMunger that figures out the path.

Film Title Sort Title Unique ID Title Catalog Title Filename Directory Path
V. I. Warshawski vi_warshawski vi_warshawski-1991-1 V.I. Warshawski (1991) vi_warshawski v/vii
The Whole Nine Yards whole_nineyards+the whole_nineyards+the-2000-1 The Whole Nine Yards (2000) the_whole_nine_yards w/whs
3:10 To Yuma three_ten_to_yuma three_ten_to_yuma-1957-1 3:10 To Yuma (1957) 310_to_yuma 3/31a

The path expression is based on the first letter of the first word in the title (unless that word is an article like 'the' or 'a'), followed by the first two letters and then the last letter of the title.

Create a method in the TitleMunger class to generate the path information and return it as a string.

cjcodeproj commented 10 months ago

Commit:

https://github.com/cjcodeproj/medialibrary/commit/47ad91d8b9797555a7c6d25ee34bd14061d94e9c

cjcodeproj commented 10 months ago

Closing Notes

Unit tests have been added for the TitleMunger() class.