Skip to content

Commit

Permalink
add: mark wrong lyrics for album
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddxxx committed Jan 21, 2019
1 parent 5f7f483 commit ff623c1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
9 changes: 6 additions & 3 deletions LyricsX/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -329,6 +329,9 @@
<action selector="wrongLyrics:" target="Ady-hI-5gd" id="PSJ-f3-tnK"/>
</connections>
</menuItem>
<menuItem title="Wrong Lyrics for Album" id="hgd-IJ-u14">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Write to iTunes" tag="202" identifier="MainMenu.WriteToiTunes" id="kNl-ZO-aX6">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand Down Expand Up @@ -1177,7 +1180,7 @@ IA
</scene>
</scenes>
<resources>
<image name="NSApplicationIcon" width="128" height="128"/>
<image name="NSApplicationIcon" width="32" height="32"/>
<image name="donate_alipay" width="200" height="200"/>
<image name="hud_button_lock_off" width="11" height="11"/>
<image name="hud_button_lock_on" width="11" height="11"/>
Expand Down
6 changes: 5 additions & 1 deletion LyricsX/Component/AppController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ class AppController: NSObject, MusicPlayerManagerDelegate {
let title = track.title ?? ""
let artist = track.artist ?? ""

guard !defaults[.NoSearchingTrackIds].contains(track.id) else {
guard !defaults[.NoSearchingTrackIds].contains(track.id),
!defaults[.NoSearchingAlbumNames].contains(track.album ?? "") else {
return
}

Expand Down Expand Up @@ -281,5 +282,8 @@ extension AppController {
if let index = defaults[.NoSearchingTrackIds].firstIndex(of: track.id) {
defaults[.NoSearchingTrackIds].remove(at: index)
}
if let index = defaults[.NoSearchingAlbumNames].firstIndex(of: track.album ?? "") {
defaults[.NoSearchingAlbumNames].remove(at: index)
}
}
}
15 changes: 15 additions & 0 deletions LyricsX/Component/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, NSTouchBarPr
AppController.shared.currentLyrics = nil
}

@IBAction func doNotSearchLyricsForThisAlbum(_ sender: Any?) {
guard let track = AppController.shared.playerManager.player?.currentTrack,
let album = track.album else {
return
}
defaults[.NoSearchingAlbumNames].append(album)
if defaults[.WriteToiTunesAutomatically] {
track.setLyrics("")
}
if let url = AppController.shared.currentLyrics?.metadata.localURL {
try? FileManager.default.removeItem(at: url)
}
AppController.shared.currentLyrics = nil
}

func registerUserDefaults() {
let currentLang = NSLocale.preferredLanguages.first!
let isZh = currentLang.hasPrefix("zh") || currentLang.hasPrefix("yue")
Expand Down
10 changes: 7 additions & 3 deletions LyricsX/Controller/SearchLyricsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ class SearchLyricsViewController: NSViewController, NSTableViewDelegate, NSTable
return
}

if let id = AppController.shared.playerManager.player?.currentTrack?.id,
let index = defaults[.NoSearchingTrackIds].firstIndex(of: id) {
defaults[.NoSearchingTrackIds].remove(at: index)
if let track = AppController.shared.playerManager.player?.currentTrack {
if let index = defaults[.NoSearchingTrackIds].firstIndex(of: track.id) {
defaults[.NoSearchingTrackIds].remove(at: index)
}
if let index = defaults[.NoSearchingAlbumNames].firstIndex(of: track.album ?? "") {
defaults[.NoSearchingAlbumNames].remove(at: index)
}
}

let lrc = searchResult[index]
Expand Down
2 changes: 2 additions & 0 deletions LyricsX/Utility/Global.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let lyricsXErrorDomain = "ddddxxx.LyricsX"

let defaults = UserDefaults.standard
let groupDefaults = UserDefaults(suiteName: lyricsXGroupIdentifier)!
let defaultNC = NotificationCenter.default
let workspaceNC = NSWorkspace.shared.notificationCenter

let isInSandbox = ProcessInfo.processInfo.environment["APP_SANDBOX_CONTAINER_ID"] != nil
Expand Down Expand Up @@ -78,6 +79,7 @@ extension UserDefaults.DefaultsKeys {

static let NotifiedUpdateVersion = Key<String?>("NotifiedUpdateVersion")
static let NoSearchingTrackIds = Key<[String]>("NoSearchingTrackIds")
static let NoSearchingAlbumNames = Key<[String]>("NoSearchingAlbumNames")

// Menu
static let DesktopLyricsEnabled = Key<Bool>("DesktopLyricsEnabled")
Expand Down

0 comments on commit ff623c1

Please sign in to comment.