Skip to content
This repository was archived by the owner on Jul 19, 2021. It is now read-only.

Commit ecdc6b4

Browse files
author
Maximilian Krauss
committed
Disabled Spotify local API
1 parent a41646b commit ecdc6b4

File tree

6 files changed

+42
-13
lines changed

6 files changed

+42
-13
lines changed

Winfy.Core/CoverService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public string FetchCover(string artist, string track) {
5353
}
5454

5555
private string FetchSpotifyCover(string cachedFileName) {
56+
return string.Empty;
57+
5658
if (!_LocalApi.HasValidToken)
5759
return string.Empty;
5860

Winfy.Core/JsonPersister.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ public JsonPersister(string path) {
2020

2121
public T Instance {
2222
get {
23-
return _Instance ?? (_Instance = File.Exists(Path)
24-
? Serializer.DeserializeFromJson<T>(Path)
25-
: Activator.CreateInstance<T>());
23+
try {
24+
return _Instance ?? (_Instance = File.Exists(Path)
25+
? Serializer.DeserializeFromJson<T>(Path)
26+
: Activator.CreateInstance<T>());
27+
}
28+
catch {
29+
return (_Instance = Activator.CreateInstance<T>());
30+
}
2631
}
2732
}
2833

Winfy.Core/SpotifyLocal/SpotifyLocalApi.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ Copyright [yyyy] [name of copyright owner]
7171

7272
/// <summary>Initializes a new SpotifyAPI object which can be used to recieve</summary>
7373
public SpotifyLocalApi(ILog log, AppContracts contracts, AppSettings settings) {
74-
74+
75+
return;
76+
7577
//emulate the embed code [NEEDED]
7678
_Client = new WebClient();
7779
_Client.Headers.Add("Origin", "https://embed.spotify.com");
@@ -89,6 +91,8 @@ public SpotifyLocalApi(ILog log, AppContracts contracts, AppSettings settings) {
8991

9092
public void RenewToken() {
9193
try {
94+
return;
95+
9296
//Reset fields
9397
_OAuth = string.Empty;
9498
_Cfid = string.Empty;
@@ -109,6 +113,8 @@ public bool HasValidToken {
109113
/// <param name="uri">The Spotify album URI</param>
110114
public string GetArt(string uri) {
111115
try {
116+
return string.Empty;
117+
112118
var albumId = uri.Split(new[] {":"}, StringSplitOptions.RemoveEmptyEntries).Last();
113119
var lines = _Client.DownloadString(string.Format("http://open.spotify.com/album/{0}", albumId))
114120
.Replace("\t", string.Empty)
@@ -199,6 +205,8 @@ public Status Pause {
199205
public Status Status {
200206
get {
201207
try {
208+
return null;
209+
202210
var a = SendLocalRequest("remote/status.json", true, true, _Wait);
203211
var d = (List<Status>) JsonConvert.DeserializeObject(a, typeof (List<Status>));
204212

Winfy/AppWindowManager.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void SetupShell(Window window) {
6262
DwmSetWindowAttribute(helper.Handle, 2, ref val, 4);
6363
var m = new Margins { bottomHeight = -1, leftWidth = -1, rightWidth = -1, topHeight = -1 };
6464
DwmExtendFrameIntoClientArea(helper.Handle, ref m);
65-
IntPtr hwnd = new WindowInteropHelper(window).Handle;
65+
var hwnd = new WindowInteropHelper(window).Handle;
6666
};
6767
window.MouseLeftButtonDown += (o, e) => window.DragMove();
6868

@@ -77,22 +77,28 @@ private void TrackLocation(Window wnd, object rootViewModel) {
7777
var wndId = rootViewModel.GetType().Name.ToSHA1();
7878

7979
var savedPosition = _Settings.Positions.FirstOrDefault(p => p.WindowId == wndId);
80-
if (savedPosition == null) {
81-
wnd.WindowStartupLocation = wnd.Owner != null
82-
? WindowStartupLocation.CenterOwner
83-
: WindowStartupLocation.CenterScreen;
84-
}
85-
else {
80+
if (savedPosition != null) {
8681
wnd.WindowStartupLocation = WindowStartupLocation.Manual;
8782
wnd.Top = savedPosition.Top;
8883
wnd.Left = savedPosition.Left;
8984
}
85+
else
86+
wnd.WindowStartupLocation = wnd.Owner != null
87+
? WindowStartupLocation.CenterOwner
88+
: WindowStartupLocation.CenterScreen;
9089

9190
if (savedPosition == null) {
9291
savedPosition = new WindowPosition {WindowId = wndId};
9392
_Settings.Positions.Add(savedPosition);
9493
}
9594

95+
//Track the location of the Shell any time its changed
96+
if (rootViewModel is ShellViewModel)
97+
wnd.LocationChanged += (o, e) => {
98+
savedPosition.Top = ((Window) o).Top;
99+
savedPosition.Left = ((Window) o).Left;
100+
};
101+
96102
wnd.Closing += (o, e) => {
97103
savedPosition.Top = ((Window) o).Top;
98104
savedPosition.Left = ((Window) o).Left;

Winfy/Views/ShellView.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<MenuItem Header="About Winfy..." cal:Message.Attach="[Event Click] = [Action ShowAbout]" />
6666
<MenuItem Header="Settings..." cal:Message.Attach="[Event Click] = [Action ShowSettings]" />
6767
<Separator/>
68-
<MenuItem Header="Play/Pause" cal:Message.Attach="[Event Click] = [Action PlayPause]" />
68+
<MenuItem Header="Toggle playback" cal:Message.Attach="[Event Click] = [Action PlayPause]" />
6969
<MenuItem Header="Previous track" cal:Message.Attach="[Event Click] = [Action PlayPrevious]" />
7070
<MenuItem Header="Next track" cal:Message.Attach="[Event Click] = [Action PlayNext]" />
7171
<Separator/>
@@ -109,7 +109,7 @@
109109
ImageSourceNormal="/Images/Player/play-pause-normal.png"
110110
ImageSource="/Images/Player/play-pause-normal.png"
111111
ImageSourcePressed="/Images/Player/play-pause-pressed.png"
112-
ToolTip="play/pause"/>
112+
ToolTip="Toggle playback"/>
113113
<ctrl:ImageButton Width="24" Height="25" x:Name="PlayNext"
114114
ImageSourceNormal="/Images/Player/next-normal.png"
115115
ImageSource="/Images/Player/next-normal.png"

Winfy/changelog.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"version": "2.0.1.5",
4+
"description": "bugfix",
5+
"changes": [
6+
"Fixed: Corrupt settings file could crash whole app",
7+
"Important: Looks like Spotify killed the Local-Api. I had to disable the interaction with the Spotify client which causes some lags in determining the current cover image."
8+
]
9+
},
210
{
311
"version": "2.0.1.4",
412
"description": "buttons!",

0 commit comments

Comments
 (0)