Archived
1

Added preference for the used iTunes Store.

This commit is contained in:
Kim Wittenburg
2015-09-16 19:41:44 +02:00
committed by Kim Wittenburg
parent 548214479a
commit 8d4fba8d8a
6 changed files with 98 additions and 17 deletions

View File

@@ -5,7 +5,7 @@ Version 1.0
Version 1.1
Added:
+ 'Try again' option for errors.
+ 'Try again' option for errors
+ Options for tags not to be saved
+ Option to use censored names
+ Option for case (in)sensitivity
@@ -19,4 +19,5 @@ Fixed:
Version 1.2
Added:
+ Option for displayed number of search results
+ Option for displayed number of search results
+ Option to change the iTunes Store used to get tags

View File

@@ -24,6 +24,9 @@ The first release of TagTunes includes all functions needed to clean your iTunes
#### How does TagTunes work?
> TagTunes uses Apple's [Search API][Search API] to get its tags.
#### TagTunes does not find an album but iTunes does
> There is a different iTunes Store for each country. By default TagTunes uses a store based on your current system settings. You can change the store used by TagTunes in the preferences.
#### The tags I got from TagTunes differ from the one's in the iTunes Store.
> Unfortunately Apple's Search API does not always return the name results as the iTunes Store does. This mainly affects composers (which aren't returned by the Search API at all) and track titles.

View File

@@ -760,11 +760,11 @@ CA
<objects>
<viewController title="General" id="tzd-4a-CRb" customClass="GeneralPreferencesViewController" customModule="TagTunes" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="pOc-Vr-IET" customClass="PreferenceView" customModule="AppKitPlus">
<rect key="frame" x="0.0" y="0.0" width="450" height="250"/>
<rect key="frame" x="0.0" y="0.0" width="450" height="315"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="kl3-n8-T9b">
<rect key="frame" x="18" y="214" width="188" height="18"/>
<rect key="frame" x="18" y="279" width="188" height="18"/>
<animations/>
<buttonCell key="cell" type="check" title="Automatically Save Artwork" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="q2l-4t-mL0">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -776,7 +776,7 @@ CA
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1fj-p7-sMs">
<rect key="frame" x="339" y="180" width="97" height="32"/>
<rect key="frame" x="339" y="245" width="97" height="32"/>
<animations/>
<buttonCell key="cell" type="push" title="Choose…" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="A5S-ps-EYW">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -787,7 +787,7 @@ CA
</connections>
</button>
<pathControl horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pT8-NA-x3W">
<rect key="frame" x="20" y="186" width="317" height="22"/>
<rect key="frame" x="20" y="251" width="317" height="22"/>
<animations/>
<pathCell key="cell" selectable="YES" alignment="left" id="Sgq-Mk-WnH">
<font key="font" metaFont="system"/>
@@ -802,7 +802,7 @@ CA
</connections>
</pathControl>
<button translatesAutoresizingMaskIntoConstraints="NO" id="iE4-HP-hS8">
<rect key="frame" x="18" y="162" width="160" height="18"/>
<rect key="frame" x="18" y="227" width="160" height="18"/>
<animations/>
<buttonCell key="cell" type="check" title="Overwrite existing files" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="WQN-Bj-me1">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -813,7 +813,7 @@ CA
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="MSr-08-ucR">
<rect key="frame" x="18" y="142" width="147" height="18"/>
<rect key="frame" x="18" y="207" width="147" height="18"/>
<animations/>
<buttonCell key="cell" type="check" title="Keep Search Results" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="uED-ee-Oc7">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -824,7 +824,7 @@ CA
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QNf-Uy-bMT">
<rect key="frame" x="30" y="122" width="338" height="14"/>
<rect key="frame" x="30" y="187" width="338" height="14"/>
<animations/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="If checked the search results are not hidden if a result is added." id="Lnf-PQ-PX4">
<font key="font" metaFont="smallSystem"/>
@@ -854,7 +854,7 @@ CA
</textFieldCell>
</textField>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dA4-F6-y0G">
<rect key="frame" x="227" y="89" width="19" height="27"/>
<rect key="frame" x="227" y="154" width="19" height="27"/>
<animations/>
<stepperCell key="cell" continuous="YES" alignment="left" minValue="1" maxValue="200" doubleValue="1" id="qF2-IP-GuD"/>
<connections>
@@ -862,7 +862,7 @@ CA
</connections>
</stepper>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tZ6-50-jBC">
<rect key="frame" x="18" y="95" width="98" height="17"/>
<rect key="frame" x="18" y="160" width="98" height="17"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Search Results:" id="aTC-x8-iNw">
<font key="font" metaFont="system"/>
@@ -871,7 +871,7 @@ CA
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fxp-Bf-M0J">
<rect key="frame" x="122" y="92" width="100" height="22"/>
<rect key="frame" x="122" y="157" width="100" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="Slg-G8-db4"/>
</constraints>
@@ -889,16 +889,59 @@ CA
<binding destination="aSx-iH-PLA" name="value" keyPath="sharedPreferences.numberOfSearchResults" id="qrT-Ml-RRF"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QpH-uA-EUO">
<rect key="frame" x="18" y="131" width="84" height="17"/>
<animations/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="iTunes Store:" id="M6p-MI-JS7">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="k1x-7X-WP5">
<rect key="frame" x="106" y="125" width="105" height="26"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="FjM-26-Vzy"/>
</constraints>
<animations/>
<popUpButtonCell key="cell" type="push" title="France" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="4uq-xu-5SH" id="0ry-cV-J7h">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="Snk-Ps-hdB">
<items>
<menuItem title="USA" id="WU9-6P-XkO"/>
<menuItem title="Germany" id="Nfg-BS-mUU"/>
<menuItem title="France" state="on" id="4uq-xu-5SH"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<binding destination="tzd-4a-CRb" name="content" keyPath="iTunesStores" id="2yF-K3-Y81"/>
<binding destination="tzd-4a-CRb" name="selectedIndex" keyPath="currentITunesStoreIndex" previousBinding="2yF-K3-Y81" id="5fE-u9-14f"/>
</connections>
</popUpButton>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gzG-qy-YYr">
<rect key="frame" x="30" y="92" width="402" height="28"/>
<animations/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="xMj-9f-8N6">
<font key="font" metaFont="smallSystem"/>
<string key="title">There is some music that does not exist in all iTunes Stores. You can select a country to search the iTunes Store for that country.</string>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="ODz-LZ-Acs" firstAttribute="leading" secondItem="HT2-V6-Vrs" secondAttribute="leading" constant="12" id="43G-D5-Hml"/>
<constraint firstItem="iE4-HP-hS8" firstAttribute="top" secondItem="pT8-NA-x3W" secondAttribute="bottom" constant="8" symbolic="YES" id="6bw-if-uzQ"/>
<constraint firstItem="QpH-uA-EUO" firstAttribute="leading" secondItem="kl3-n8-T9b" secondAttribute="leading" id="AyN-WL-ftj"/>
<constraint firstItem="dA4-F6-y0G" firstAttribute="centerY" secondItem="Fxp-Bf-M0J" secondAttribute="centerY" id="Bpw-lV-2J4"/>
<constraint firstItem="QNf-Uy-bMT" firstAttribute="leading" secondItem="MSr-08-ucR" secondAttribute="leading" constant="12" id="CMf-fg-xwn"/>
<constraint firstItem="1fj-p7-sMs" firstAttribute="baseline" secondItem="pT8-NA-x3W" secondAttribute="baseline" id="Cbb-Md-hLt"/>
<constraint firstItem="1fj-p7-sMs" firstAttribute="leading" secondItem="pT8-NA-x3W" secondAttribute="trailing" constant="8" symbolic="YES" id="EBN-ov-eyz"/>
<constraint firstItem="HT2-V6-Vrs" firstAttribute="top" secondItem="Fxp-Bf-M0J" secondAttribute="bottom" constant="8" symbolic="YES" id="In7-42-Jas"/>
<constraint firstItem="gzG-qy-YYr" firstAttribute="top" secondItem="k1x-7X-WP5" secondAttribute="bottom" constant="8" symbolic="YES" id="Hxs-tl-t1n"/>
<constraint firstItem="MSr-08-ucR" firstAttribute="top" secondItem="iE4-HP-hS8" secondAttribute="bottom" constant="6" symbolic="YES" id="JSO-qU-fYO"/>
<constraint firstItem="k1x-7X-WP5" firstAttribute="baseline" secondItem="QpH-uA-EUO" secondAttribute="baseline" id="RFw-e1-Vzx"/>
<constraint firstItem="pT8-NA-x3W" firstAttribute="leading" secondItem="kl3-n8-T9b" secondAttribute="leading" id="RTj-aH-O8R"/>
<constraint firstItem="HT2-V6-Vrs" firstAttribute="leading" secondItem="kl3-n8-T9b" secondAttribute="leading" id="S3T-h3-Fog"/>
<constraint firstItem="tZ6-50-jBC" firstAttribute="leading" secondItem="kl3-n8-T9b" secondAttribute="leading" id="STK-6T-Khg"/>
@@ -908,12 +951,17 @@ CA
<constraint firstItem="Fxp-Bf-M0J" firstAttribute="baseline" secondItem="tZ6-50-jBC" secondAttribute="baseline" id="VXj-Af-rHF"/>
<constraint firstItem="Fxp-Bf-M0J" firstAttribute="leading" secondItem="tZ6-50-jBC" secondAttribute="trailing" constant="8" symbolic="YES" id="btn-6X-YVa"/>
<constraint firstAttribute="trailing" secondItem="1fj-p7-sMs" secondAttribute="trailing" constant="20" symbolic="YES" id="ePv-QH-p9T"/>
<constraint firstItem="gzG-qy-YYr" firstAttribute="leading" secondItem="QpH-uA-EUO" secondAttribute="leading" constant="12" id="f6O-eW-sug"/>
<constraint firstItem="pT8-NA-x3W" firstAttribute="top" secondItem="kl3-n8-T9b" secondAttribute="bottom" constant="8" symbolic="YES" id="hUh-aB-iwg"/>
<constraint firstItem="HT2-V6-Vrs" firstAttribute="top" secondItem="gzG-qy-YYr" secondAttribute="bottom" constant="8" symbolic="YES" id="iEX-pY-uV1"/>
<constraint firstItem="kl3-n8-T9b" firstAttribute="leading" secondItem="pOc-Vr-IET" secondAttribute="leading" constant="20" symbolic="YES" id="kt7-6h-DFt"/>
<constraint firstItem="iE4-HP-hS8" firstAttribute="leading" secondItem="kl3-n8-T9b" secondAttribute="leading" id="mFQ-g8-Z2O"/>
<constraint firstItem="k1x-7X-WP5" firstAttribute="leading" secondItem="QpH-uA-EUO" secondAttribute="trailing" constant="8" symbolic="YES" id="mV0-kX-iRw"/>
<constraint firstItem="kl3-n8-T9b" firstAttribute="top" secondItem="pOc-Vr-IET" secondAttribute="top" constant="20" symbolic="YES" id="mW3-jS-00k"/>
<constraint firstItem="ODz-LZ-Acs" firstAttribute="top" secondItem="HT2-V6-Vrs" secondAttribute="bottom" constant="8" symbolic="YES" id="nwg-Wk-kB9"/>
<constraint firstAttribute="trailing" secondItem="gzG-qy-YYr" secondAttribute="trailing" constant="20" symbolic="YES" id="olE-ik-03R"/>
<constraint firstItem="MSr-08-ucR" firstAttribute="leading" secondItem="kl3-n8-T9b" secondAttribute="leading" id="pIO-CH-97G"/>
<constraint firstItem="k1x-7X-WP5" firstAttribute="top" secondItem="Fxp-Bf-M0J" secondAttribute="bottom" constant="8" id="qZT-tg-7H0"/>
</constraints>
<animations/>
<userDefinedRuntimeAttributes>
@@ -921,7 +969,7 @@ CA
<real key="value" value="450"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="height">
<real key="value" value="250"/>
<real key="value" value="315"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
@@ -933,7 +981,7 @@ CA
<customObject id="RtZ-4O-Pgk" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
<customObject id="aSx-iH-PLA" userLabel="Preferences" customClass="PreferencesSingleton" customModule="TagTunes" customModuleProvider="target"/>
</objects>
<point key="canvasLocation" x="-1031" y="1112"/>
<point key="canvasLocation" x="-1031" y="1144.5"/>
</scene>
<!--Tags-->
<scene sceneID="oNy-iK-NsG">

View File

@@ -42,6 +42,20 @@ internal class GeneralPreferencesViewController: NSViewController {
}
}
dynamic var iTunesStores: [String] {
return NSLocale.ISOCountryCodes().map { NSLocale.currentLocale().displayNameForKey(NSLocaleCountryCode, value: $0)! }
}
dynamic var currentITunesStoreIndex: Int {
set {
let countryCode = NSLocale.ISOCountryCodes()[newValue]
Preferences.sharedPreferences.iTunesStore = countryCode
}
get {
return NSLocale.ISOCountryCodes().indexOf(Preferences.sharedPreferences.iTunesStore)!
}
}
}
internal class TagsPreferencesViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate, NSMenuDelegate {

View File

@@ -38,6 +38,8 @@ import Cocoa
static let numberOfSearchResultsKey = "Number of Search Results"
static let iTunesStoreKey = "iTunes Store"
static let removeSavedAlbumsKey = "Remove Saved Albums"
static let useLowResolutionArtworkKey = "Use Low Resolution Artwork"
@@ -79,6 +81,7 @@ import Cocoa
UserDefaultsConstants.overwriteExistingFilesKey: false,
UserDefaultsConstants.keepSearchResultsKey: false,
UserDefaultsConstants.numberOfSearchResultsKey: 10,
UserDefaultsConstants.iTunesStoreKey: NSLocale.currentLocale().objectForKey(NSLocaleCountryCode)!,
UserDefaultsConstants.removeSavedAlbumsKey: false,
UserDefaultsConstants.useLowResolutionArtworkKey: false,
UserDefaultsConstants.useCensoredNamesKey: false,
@@ -150,6 +153,18 @@ import Cocoa
}
}
/// The iTunes Store from which the metadata should be loaded.
///
/// The value of this property must be a valid two-letter ISO country code.
public dynamic var iTunesStore: String {
set {
NSUserDefaults.standardUserDefaults().setObject(newValue, forKey: UserDefaultsConstants.iTunesStoreKey)
}
get {
return NSUserDefaults.standardUserDefaults().stringForKey(UserDefaultsConstants.iTunesStoreKey)!
}
}
/// If `true` the main table view will use 100x100 artworks instead of full
/// sized images. This option does not affect saving.
public dynamic var useLowResolutionArtwork: Bool {

View File

@@ -129,7 +129,7 @@ public struct iTunesAPI {
if searchTerm.isEmpty {
return nil
}
return NSURL(string: "https://itunes.apple.com/search?term=\(searchTerm)&media=music&entity=album&limit=\(Preferences.sharedPreferences.numberOfSearchResults)&country=de&lang=de_DE")
return NSURL(string: "https://itunes.apple.com/search?term=\(searchTerm)&media=music&entity=album&limit=\(Preferences.sharedPreferences.numberOfSearchResults)&country=\(Preferences.sharedPreferences.iTunesStore)")
}
/// Creates an URL that looks up all tracks that belong to the album with the
@@ -138,7 +138,7 @@ public struct iTunesAPI {
///
/// This function respects the user's preferences (See `Preferences` class).
public static func createAlbumLookupURLForId(id: iTunesId) -> NSURL {
return NSURL(string: "http://itunes.apple.com/lookup?id=\(id)&entity=song&country=de&lang=de_DE&limit=200")!
return NSURL(string: "http://itunes.apple.com/lookup?id=\(id)&entity=song&country=\(Preferences.sharedPreferences.iTunesStore)&limit=200")!
}
}