Skip to content

Commit 0d55f4d

Browse files
author
Johnny-Laptop
committed
Initial Commit
1 parent b68f0db commit 0d55f4d

13 files changed

Lines changed: 477 additions & 0 deletions

File tree

‎DebugExample/App.config‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

‎DebugExample/DebugExample.csproj‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{41F89F0F-4D54-4551-B352-460BA6AB89BB}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>DebugExample</RootNamespace>
11+
<AssemblyName>DebugExample</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<PropertyGroup>
35+
<StartupObject>DebugExample.Program</StartupObject>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
39+
<SpecificVersion>False</SpecificVersion>
40+
<HintPath>..\Newtonsoft.Json.dll</HintPath>
41+
</Reference>
42+
<Reference Include="SpotifyAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
43+
<SpecificVersion>False</SpecificVersion>
44+
<HintPath>bin\Debug\SpotifyAPI.dll</HintPath>
45+
</Reference>
46+
<Reference Include="System" />
47+
<Reference Include="System.Core" />
48+
<Reference Include="System.Xml.Linq" />
49+
<Reference Include="System.Data.DataSetExtensions" />
50+
<Reference Include="Microsoft.CSharp" />
51+
<Reference Include="System.Data" />
52+
<Reference Include="System.Xml" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Compile Include="Program.cs" />
56+
<Compile Include="Properties\AssemblyInfo.cs" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<None Include="App.config" />
60+
</ItemGroup>
61+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
62+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
63+
Other similar extension points exist, see Microsoft.Common.targets.
64+
<Target Name="BeforeBuild">
65+
</Target>
66+
<Target Name="AfterBuild">
67+
</Target>
68+
-->
69+
</Project>

‎DebugExample/Program.cs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using SpotifyAPIv1;
7+
using System.Threading;
8+
9+
namespace DebugExample
10+
{
11+
class Program
12+
{
13+
static void Main(string[] args)
14+
{
15+
SpotifyAPI test = new SpotifyAPI();
16+
test.Connect();
17+
Thread.Sleep(-1);
18+
}
19+
}
20+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// Allgemeine Informationen über eine Assembly werden über die folgenden
6+
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7+
// die mit einer Assembly verknüpft sind.
8+
[assembly: AssemblyTitle("DebugExample")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("DebugExample")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
18+
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
19+
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
20+
[assembly: ComVisible(false)]
21+
22+
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23+
[assembly: Guid("9a361bab-2331-48d0-b06d-13255944de54")]
24+
25+
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26+
//
27+
// Hauptversion
28+
// Nebenversion
29+
// Buildnummer
30+
// Revision
31+
//
32+
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
33+
// übernehmen, indem Sie "*" eingeben:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

‎SpotifyAPI.sln‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.21005.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyAPI", "SpotifyAPI\SpotifyAPI.csproj", "{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugExample", "DebugExample\DebugExample.csproj", "{41F89F0F-4D54-4551-B352-460BA6AB89BB}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{EBBE35E2-7B91-4D7D-B8FC-3A0472F5119D}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{41F89F0F-4D54-4551-B352-460BA6AB89BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{41F89F0F-4D54-4551-B352-460BA6AB89BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{41F89F0F-4D54-4551-B352-460BA6AB89BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{41F89F0F-4D54-4551-B352-460BA6AB89BB}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal

‎SpotifyAPI/CFID.cs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SpotifyAPIv1
8+
{
9+
class CFID
10+
{
11+
public String error { get; set; }
12+
public String token { get; set; }
13+
}
14+
}

‎SpotifyAPI/MusicHandler.cs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SpotifyAPIv1
8+
{
9+
class MusicHandler
10+
{
11+
12+
public MusicHandler()
13+
{
14+
15+
}
16+
17+
public void Update()
18+
{
19+
20+
}
21+
}
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// Allgemeine Informationen über eine Assembly werden über die folgenden
6+
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7+
// die mit einer Assembly verknüpft sind.
8+
[assembly: AssemblyTitle("SpotifyAPI")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("SpotifyAPI")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
18+
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
19+
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
20+
[assembly: ComVisible(false)]
21+
22+
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23+
[assembly: Guid("3a30f0ac-4874-4d18-ba0e-d20d0f67ed32")]
24+
25+
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26+
//
27+
// Hauptversion
28+
// Nebenversion
29+
// Buildnummer
30+
// Revision
31+
//
32+
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
33+
// übernehmen, indem Sie "*" eingeben:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

‎SpotifyAPI/RemoteHandler.cs‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Net;
7+
using Newtonsoft.Json;
8+
9+
namespace SpotifyAPIv1
10+
{
11+
class RemoteHandler
12+
{
13+
private static RemoteHandler instance = new RemoteHandler();
14+
15+
public String oauthKey {get;private set;}
16+
public String cfidKey {get;private set;}
17+
18+
public String host = "127.0.0.1";
19+
20+
WebClient wc;
21+
22+
public static RemoteHandler GetInstance()
23+
{
24+
return instance;
25+
}
26+
27+
public RemoteHandler()
28+
{
29+
wc = new WebClient();
30+
wc.Headers.Add("Origin", "https://embed.spotify.com");
31+
wc.Headers.Add("Referer", "https://embed.spotify.com/?uri=spotify:track:5Zp4SWOpbuOdnsxLqwgutt");
32+
}
33+
public void Init()
34+
{
35+
oauthKey = GetOAuthKey();
36+
cfidKey = GetCFID();
37+
}
38+
private String GetOAuthKey()
39+
{
40+
String raw = "";
41+
try
42+
{
43+
raw = new WebClient().DownloadString("https://embed.spotify.com/openplay/?uri=spotify:track:5Zp4SWOpbuOdnsxLqwgutt");
44+
}
45+
catch(WebException e)
46+
{
47+
48+
}
49+
raw = raw.Replace(" ", "");
50+
string[] lines = raw.Split(new string[] { "\n" }, StringSplitOptions.None);
51+
foreach (string line in lines)
52+
{
53+
if (line.StartsWith("tokenData"))
54+
{
55+
string[] l = line.Split(new string[] { "'" }, StringSplitOptions.None);
56+
return l[1];
57+
}
58+
}
59+
throw new Exception("OAuth Token konnte nicht gefunden werden");
60+
}
61+
62+
private String GetCFID()
63+
{
64+
string a = recv("simplecsrf/token.json", false, false, -1);
65+
List<CFID> d = (List<CFID>)JsonConvert.DeserializeObject(a, typeof(List<CFID>));
66+
if (d.Count != 1)
67+
throw new Exception("CFID konnte nicht geladen werden.");
68+
return d[0].token;
69+
}
70+
private string recv(string request, bool oauth, bool cfid, int wait)
71+
{
72+
string parameters = "?&ref=&cors=&_=" + "";
73+
if (request.Contains("?"))
74+
{
75+
parameters = parameters.Substring(1);
76+
}
77+
78+
if (oauth)
79+
{
80+
parameters += "&oauth=" + oauthKey;
81+
}
82+
if (cfid)
83+
{
84+
parameters += "&csrf=" + cfidKey;
85+
}
86+
87+
if (wait != -1)
88+
{
89+
parameters += "&returnafter=" + wait;
90+
parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap";
91+
}
92+
93+
string a = "http://" + host + ":4380/" + request + parameters;
94+
string derp = "";
95+
try
96+
{
97+
derp = wc.DownloadString(a);
98+
derp = "[ " + derp + " ]";
99+
}
100+
catch (Exception z)
101+
{
102+
103+
}
104+
return derp;
105+
}
106+
}
107+
}

0 commit comments

Comments
 (0)