Playlist Loader: Add option to skip playlists

When parsing folders, add option to skip importing playlist files.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-03-09 23:01:40 -07:00
parent 2042034868
commit 2733ee95f3
4 changed files with 113 additions and 59 deletions

View file

@ -65,8 +65,9 @@ extern NSMutableDictionary<NSString *, AlbumArtwork *> *kArtworkDictionary;
}
- (void)initDefaults {
NSDictionary *defaultsDictionary = @{ @"readCueSheetsInFolders": @(YES),
@"addOtherFilesInFolders": @(NO) };
NSDictionary *defaultsDictionary = @{ @"readCueSheetsInFolders": @NO,
@"readPlaylistsInFolders": @NO,
@"addOtherFilesInFolders": @NO };
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
}
@ -252,13 +253,24 @@ NSMutableDictionary *dictionaryWithPropertiesOfObject(id obj, NSArray *filterLis
NSArray *subpaths = [manager subpathsAtPath:path];
[[SandboxBroker sharedSandboxBroker] endFolderAccess:sbHandle];
BOOL readCueSheets = [[NSUserDefaults standardUserDefaults] boolForKey:@"readCueSheetsInFolders"];
BOOL readPlaylists = [[NSUserDefaults standardUserDefaults] boolForKey:@"readPlaylistsInFolders"];
for(NSString *subpath in subpaths) {
NSString *absoluteSubpath = [NSString pathWithComponents:@[path, subpath]];
BOOL isDir;
if([manager fileExistsAtPath:absoluteSubpath isDirectory:&isDir] && isDir == NO) {
if([[absoluteSubpath pathExtension] caseInsensitiveCompare:@"cue"] != NSOrderedSame ||
[[NSUserDefaults standardUserDefaults] boolForKey:@"readCueSheetsInFolders"]) {
BOOL readFile = YES;
NSString *ext = [absoluteSubpath pathExtension];
if([ext caseInsensitiveCompare:@"cue"] == NSOrderedSame) {
readFile = readCueSheets;
} else if([ext caseInsensitiveCompare:@"m3u"] == NSOrderedSame ||
[ext caseInsensitiveCompare:@"m3u8"] == NSOrderedSame ||
[ext caseInsensitiveCompare:@"pls"] == NSOrderedSame) {
readFile = readPlaylists;
}
if(readFile) {
[urls addObject:[NSURL fileURLWithPath:absoluteSubpath]];
}
}

View file

@ -22,42 +22,20 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="231" userLabel="PlaylistView">
<rect key="frame" x="0.0" y="0.0" width="640" height="201"/>
<rect key="frame" x="0.0" y="0.0" width="640" height="229"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="310">
<rect key="frame" x="18" y="103" width="602" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Read CUE sheets when adding folders to playlist" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="311">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.readCueSheetsInFolders" id="328"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="261">
<rect key="frame" x="18" y="127" width="180" height="35"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="When opening file with ⇧ or ⌃⌘ held:" id="262">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="259">
<rect key="frame" x="18" y="168" width="180" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="259">
<rect key="frame" x="18" y="196" width="180" height="17"/>
<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="When opening files:" id="260">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="247">
<rect key="frame" x="201" y="161" width="423" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="250" id="248">
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="247" userLabel="Open Files Action">
<rect key="frame" x="201" y="189" width="423" height="26"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="250" id="248" userLabel="Open Files Action">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="message"/>
<menu key="menu" title="OtherViews" id="249">
@ -75,32 +53,20 @@
<binding destination="52" name="selectedObject" keyPath="values.openingFilesBehavior" previousBinding="305" id="306"/>
</connections>
</popUpButton>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6QS-GF-Vnc">
<rect key="frame" x="18" y="47" width="602" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Resume playback on startup" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="fUg-Cg-gXa">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<textField verticalHuggingPriority="249" horizontalCompressionResistancePriority="250" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="261">
<rect key="frame" x="18" y="156" width="180" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="176" id="vtB-zC-liv"/>
</constraints>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="When opening file with ⇧ or ⌃⌘ held:" id="262">
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.resumePlaybackOnStartup" id="8OB-tj-Hd0"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fDV-n8-dvO">
<rect key="frame" x="18" y="19" width="602" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Quit when playback completes" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="SBA-J5-rEd">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.quitOnNaturalStop" id="T4y-d6-qSk"/>
</connections>
</button>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="253">
<rect key="frame" x="201" y="123" width="423" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" id="254">
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="253" userLabel="Alternate Open Files Action">
<rect key="frame" x="201" y="152" width="423" height="25"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" id="254" userLabel="Alternate Open Files Action">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="message"/>
<menu key="menu" title="OtherViews" id="255">
@ -118,9 +84,28 @@
<binding destination="52" name="selectedObject" keyPath="values.openingFilesAlteredBehavior" previousBinding="308" id="309"/>
</connections>
</popUpButton>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RiU-1B-ZKm">
<button translatesAutoresizingMaskIntoConstraints="NO" id="310">
<rect key="frame" x="18" y="131" width="602" height="18"/>
<buttonCell key="cell" type="check" title="Read CUE sheets when adding folders to playlist" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="311">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.readCueSheetsInFolders" id="328"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="KlR-BO-nDA" userLabel="Read playlist files when adding folders to playlist">
<rect key="frame" x="18" y="103" width="602" height="18"/>
<buttonCell key="cell" type="check" title="Read playlist files when adding folders to playlist" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="k2u-la-Kp8">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.readPlaylistsInFolders" id="u3h-pF-q8a"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RiU-1B-ZKm">
<rect key="frame" x="18" y="75" width="602" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Add other files in the same folder when adding a file" bezelStyle="regularSquare" imagePosition="left" inset="2" id="ws4-en-un8">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -129,7 +114,58 @@
<binding destination="52" name="value" keyPath="values.addOtherFilesInFolders" id="9V7-qF-e8q"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="6QS-GF-Vnc">
<rect key="frame" x="18" y="47" width="602" height="18"/>
<buttonCell key="cell" type="check" title="Resume playback on startup" bezelStyle="regularSquare" imagePosition="left" inset="2" id="fUg-Cg-gXa">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.resumePlaybackOnStartup" id="8OB-tj-Hd0"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fDV-n8-dvO">
<rect key="frame" x="18" y="19" width="602" height="18"/>
<buttonCell key="cell" type="check" title="Quit when playback completes" bezelStyle="regularSquare" imagePosition="left" inset="2" id="SBA-J5-rEd">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="52" name="value" keyPath="values.quitOnNaturalStop" id="T4y-d6-qSk"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="259" firstAttribute="firstBaseline" secondItem="247" secondAttribute="firstBaseline" id="1rv-W8-b3j"/>
<constraint firstItem="253" firstAttribute="bottom" secondItem="261" secondAttribute="bottom" id="3HA-bC-1P9"/>
<constraint firstItem="253" firstAttribute="top" secondItem="231" secondAttribute="top" constant="53" id="3mb-zQ-nlW"/>
<constraint firstAttribute="trailing" secondItem="253" secondAttribute="trailing" constant="20" symbolic="YES" id="5vB-qt-TGf"/>
<constraint firstItem="253" firstAttribute="trailing" secondItem="247" secondAttribute="trailing" id="6Cl-uh-i7K"/>
<constraint firstItem="259" firstAttribute="baseline" secondItem="247" secondAttribute="baseline" id="7L0-2P-327"/>
<constraint firstItem="RiU-1B-ZKm" firstAttribute="top" secondItem="KlR-BO-nDA" secondAttribute="bottom" constant="12" id="Emz-PP-fRt"/>
<constraint firstItem="253" firstAttribute="trailing" secondItem="KlR-BO-nDA" secondAttribute="trailing" id="HHm-Wc-CU2"/>
<constraint firstItem="253" firstAttribute="top" secondItem="247" secondAttribute="bottom" constant="17" id="Lbh-Qd-gqL"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="leading" secondItem="310" secondAttribute="leading" id="N0l-AC-spz"/>
<constraint firstItem="253" firstAttribute="trailing" secondItem="6QS-GF-Vnc" secondAttribute="trailing" id="NaS-L2-FCP"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="leading" secondItem="259" secondAttribute="leading" id="O4d-dd-gBM"/>
<constraint firstItem="253" firstAttribute="leading" secondItem="261" secondAttribute="trailing" constant="8" symbolic="YES" id="O90-wx-pXe"/>
<constraint firstItem="259" firstAttribute="top" secondItem="231" secondAttribute="top" constant="16" id="Oac-6o-08P"/>
<constraint firstItem="253" firstAttribute="leading" secondItem="247" secondAttribute="leading" id="QuJ-As-B5f"/>
<constraint firstItem="253" firstAttribute="trailing" secondItem="RiU-1B-ZKm" secondAttribute="trailing" id="gQj-9C-STs"/>
<constraint firstItem="310" firstAttribute="top" secondItem="253" secondAttribute="bottom" constant="8" id="isP-Wi-63s"/>
<constraint firstItem="253" firstAttribute="trailing" secondItem="310" secondAttribute="trailing" id="jc3-Zx-oKa"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="leading" secondItem="RiU-1B-ZKm" secondAttribute="leading" id="joE-uS-73o"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="leading" secondItem="6QS-GF-Vnc" secondAttribute="leading" id="kh0-Ij-56F"/>
<constraint firstAttribute="bottom" secondItem="fDV-n8-dvO" secondAttribute="bottom" constant="20" symbolic="YES" id="nMf-ng-RQo"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="leading" secondItem="KlR-BO-nDA" secondAttribute="leading" id="p0l-5P-8c3"/>
<constraint firstItem="247" firstAttribute="leading" secondItem="259" secondAttribute="trailing" constant="8" symbolic="YES" id="rR8-8u-bGr"/>
<constraint firstItem="KlR-BO-nDA" firstAttribute="top" secondItem="310" secondAttribute="bottom" constant="12" id="rnn-3z-Edn"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="leading" secondItem="261" secondAttribute="leading" id="wAu-BP-xVl"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="top" secondItem="6QS-GF-Vnc" secondAttribute="bottom" constant="12" id="wMq-bf-akP"/>
<constraint firstItem="261" firstAttribute="top" secondItem="259" secondAttribute="bottom" constant="6" id="wjs-Oe-Jvr"/>
<constraint firstItem="253" firstAttribute="trailing" secondItem="fDV-n8-dvO" secondAttribute="trailing" id="wqo-81-3PQ"/>
<constraint firstItem="fDV-n8-dvO" firstAttribute="leading" secondItem="231" secondAttribute="leading" constant="20" symbolic="YES" id="xGL-d8-khI"/>
</constraints>
<point key="canvasLocation" x="-151" y="-283.5"/>
</customView>
<customObject id="gKy-O9-bcf" userLabel="AppearancePane" customClass="AppearancePane">

View file

@ -77,6 +77,9 @@
/* Class = "NSButtonCell"; title = "Read CUE sheets when adding folders to playlist"; ObjectID = "311"; */
"311.title" = "Read CUE sheets when adding folders to playlist";
/* Class = "NSButtonCell"; title = "Read playlist files when adding folders to playlist"; ObjectID = "k2u-la-Kp8"; */
"k2u-la-Kp8.title" = "Read playlist files when adding folders to playlist";
/* Class = "NSTextFieldCell"; title = "Spectrum bars"; ObjectID = "Bll-IJ-lje"; */
"Bll-IJ-lje.title" = "Spectrum bars";

View file

@ -73,6 +73,9 @@
/* Class = "NSButtonCell"; title = "Read CUE sheets when adding folders to playlist"; ObjectID = "311"; */
"311.title" = "Leer las hojas CUE al añadir carpetas a la playlist";
/* Class = "NSButtonCell"; title = "Read playlist files when adding folders to playlist"; ObjectID = "k2u-la-Kp8"; */
"k2u-la-Kp8.title" = "Leer archivos de playlist al agregar carpetas a la playlist";
/* Class = "NSTextFieldCell"; title = "Spectrum bars"; ObjectID = "Bll-IJ-lje"; */
"Bll-IJ-lje.title" = "Barras del analizador";