Compare commits

...

9 commits

Author SHA1 Message Date
Norbi Peti 3634d6783e
Fix (ratelimit) error handling 2019-12-12 22:00:10 +01:00
Norbi Peti 35629a3e13
Fix random null issue - ratelimit 2019-08-09 00:31:37 +02:00
Norbi Peti ae18eea463
Added support for adding lyrics easily 2019-07-24 01:18:15 +02:00
Norbi Peti fb6246d563
Artist getting progress display 2019-07-02 21:26:53 +02:00
Norbi Peti 75cf86b363
Ordering songs and artists
This way the order won't keep changing
2019-06-13 22:20:18 +02:00
Norbi Peti 869192da61
Printing artists in array 2019-06-07 03:20:54 +02:00
Norbi Peti 1b711f4ab8
Not minifying for the sake of Git 2019-05-24 01:11:58 +02:00
Norbi Peti a4057745f1
Make it update 2019-05-24 01:06:17 +02:00
Norbi Peti 6ab4e1ed52
Add updater 2019-05-23 23:27:46 +02:00
34 changed files with 305 additions and 325 deletions

View file

@ -1,22 +0,0 @@
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# https://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[{.travis.yml,package.json}]
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
indent_size = 2
indent_style = space

28
.gitattributes vendored
View file

@ -1,28 +0,0 @@
# Automatically normalize line endings for all text-based files
# https://git-scm.com/docs/gitattributes#_end_of_line_conversion
* text=auto
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# For the following file types, normalize line endings to LF on
# checkin and prevent conversion to CRLF when they are checked out
# (this is required in order to prevent newline related issues like,
# for example, after the build script is run)
.* text eol=lf
*.css text eol=lf
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.md text eol=lf
*.sh text eol=lf
*.txt text eol=lf
*.xml text eol=lf
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Exclude the `.htaccess` file from GitHub's language statistics
# https://github.com/github/linguist#using-gitattributes
dist/.htaccess linguist-vendored

0
.gitignore vendored
View file

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jquery-3.3.1" level="application" />
</component>
</module>

View file

@ -1,15 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JSCodeStyleSettings version="0">
<option name="FORCE_SEMICOLON_STYLE" value="true" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="FORCE_QUOTE_STYlE" value="true" />
</JSCodeStyleSettings>
<codeStyleSettings language="JavaScript">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>

View file

@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="PROJECT" libraries="{jquery-3.3.1}" />
</component>
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/HS.iml" filepath="$PROJECT_DIR$/.idea/HS.iml" />
</modules>
</component>
</project>

View file

@ -1,4 +0,0 @@
---
---
<h1 style="text-align: center">Page Not Found</h1>
<p style="text-align: center">Sorry, but the page you were trying to view does not exist.</p>

BIN
HS.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 MiB

16
HS.sln Normal file
View file

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HiddenUpdater", "HiddenUpdater\HiddenUpdater.csproj", "{74B49E86-F983-4818-8A53-F4C6F69777E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{74B49E86-F983-4818-8A53-F4C6F69777E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74B49E86-F983-4818-8A53-F4C6F69777E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74B49E86-F983-4818-8A53-F4C6F69777E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74B49E86-F983-4818-8A53-F4C6F69777E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View file

@ -1,19 +0,0 @@
Copyright (c) HTML5 Boilerplate
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{74B49E86-F983-4818-8A53-F4C6F69777E2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HiddenUpdater</RootNamespace>
<AssemblyName>HiddenUpdater</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SpotifyAPI.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\SpotifyAPI.Web.4.2.0\lib\netstandard2.0\SpotifyAPI.Web.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SpotifyAPI.Web.Auth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\SpotifyAPI.Web.Auth.4.2.0\lib\netstandard2.0\SpotifyAPI.Web.Auth.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Unosquare.Labs.EmbedIO, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\EmbedIO.2.9.1\lib\netstandard2.0\Unosquare.Labs.EmbedIO.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Unosquare.Swan.Lite, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Unosquare.Swan.Lite.1.3.0\lib\net461\Unosquare.Swan.Lite.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StoreLyrics.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="secret.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

107
HiddenUpdater/Program.cs Normal file
View file

@ -0,0 +1,107 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SpotifyAPI.Web;
using SpotifyAPI.Web.Auth;
namespace HiddenUpdater
{
internal class Program
{
private const string PlaylistId = "2YDWLcBzTpDNQDfcQyy76b";
public static async Task Main(string[] args)
{
Console.Write("Download (1) or lyrics (2): ");
if (int.Parse(Console.ReadLine()) != 1)
{
StoreLyrics.Store();
return;
}
var auth = new CredentialsAuth("ce11c54b88cf41149e528de5ec73aa69", File.ReadAllText("secret.txt"));
var token = await auth.GetToken();
var spotify = new SpotifyWebAPI
{
AccessToken = token.AccessToken,
TokenType = token.TokenType
};
var playlist = spotify.GetPlaylist(PlaylistId);
Console.WriteLine(playlist);
var playlistJson = new JArray();
var tracks = playlist.Tracks;
Console.WriteLine("Total: " + tracks.Total);
int C = 0;
var artistJson = new JObject();
for (int i = 0; i < tracks.Total; i += 100)
{
if (i > 0)
tracks = spotify.GetPlaylistTracks(PlaylistId, offset: i);
foreach (var track in tracks.Items.Select(tr => tr.Track))
{
var obj = new JObject();
obj["sname"] = track.Name;
/*obj["artists"] = new JArray(track.Artists.Select(artist => new JObject
{
{"name", artist.Name},
{"url", artist.ExternalUrls["spotify"]}
}));*/
var artJson = new JArray();
foreach (var artist in track.Artists)
{
if (!artistJson.ContainsKey(artist.Name))
artistJson[artist.Name] = new JObject
{
{"sname", artist.Name},
{"surl", artist.ExternalUrls["spotify"]},
{"sid", artist.Id}
};
artJson.Add(artist.Name);
}
obj["artists"] = artJson;
obj["popularity"] = track.Popularity;
obj["durationMs"] = track.DurationMs;
obj["surl"] = track.ExternUrls["spotify"];
obj["sid"] = track.Id;
playlistJson.Add(obj);
C++;
}
}
Console.WriteLine(C + " / " + tracks.Total);
Console.WriteLine("Getting artists...");
C = 0;
int max = artistJson.Count;
foreach (var kv in artistJson)
{
var artist = spotify.GetArtist((string) kv.Value["sid"]);
var artJson = kv.Value;
if (artist.HasError())
{
Console.WriteLine(kv.Value["sid"] + " - Error: " + artist.Error.Status + " - " + artist.Error.Message);
Thread.Sleep(5000);
artist = spotify.GetArtist((string) kv.Value["sid"]);
}
artJson["followers"] = artist?.Followers?.Total;
artJson["popularity"] = artist?.Popularity;
artJson["genres"] = new JArray(artist?.Genres);
C++;
if (C % 10 == 0) Console.Write("\r" + C + "/" + max + " - " + (C / (float) max) * 100 + "%");
if(C % 100 == 0) Thread.Sleep(2000); //It exceeded the ratelimit after 120-something
}
Console.WriteLine("\r" + C + "/" + max + " - " + (C / (float) max) * 100 + "%");
//Console.WriteLine(artistJson.ToString(Formatting.None));
File.WriteAllText("songs.json", new JArray(playlistJson.OrderBy(song=>song["sid"])).ToString());
File.WriteAllText("artists.json", new JArray(artistJson.Children().Select(tk=>tk.Last)
.OrderBy(artist=>artist["sname"])).ToString());
}
}
}

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("HiddenUpdater")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HiddenUpdater")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("74B49E86-F983-4818-8A53-F4C6F69777E2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,57 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using Newtonsoft.Json.Linq;
namespace HiddenUpdater
{
public class StoreLyrics
{
public static void Store()
{
do
{
Console.Write("One artist: ");
string artist = Console.ReadLine();
if (artist.Length == 0) break;
Console.Write("Title: ");
string title = Console.ReadLine();
if (artist.Length == 0) break;
var songs = JArray.Parse(File.ReadAllText("songs.json"));
foreach (var song in songs)
{
if (((string) song["sname"]).Contains(title))
{
Console.WriteLine("Title matches: " + song["artists"] + " - " + song["sname"]);
if (song["artists"].Any(a => ((string) a).Contains(artist)))
{
Console.WriteLine("Artist matches");
/*Console.WriteLine("Lyrics (type \"END\" when done):");
string lyrics = "";
do
{
var line = Console.ReadLine();
Console.WriteLine("Line: " + line);
if (line == "END") break;
lyrics += " " + line + "\n";
} while (true);*/
File.WriteAllText("lyrics.txt", "");
Console.WriteLine("Put the lyrics in lyrics.txt and press Enter");
Console.ReadLine();
string lyrics = "";
foreach(string line in File.ReadLines("lyrics.txt")) {
Console.WriteLine("Line: " + line);
lyrics += " " + line + "\n";
}
File.AppendAllText("songextra.yml", "- sid: " + song["sid"] + "\n lyrics: |\n" + lyrics);
break;
}
}
}
} while (true);
}
}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EmbedIO" version="2.9.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
<package id="SpotifyAPI.Web" version="4.2.0" targetFramework="net472" />
<package id="SpotifyAPI.Web.Auth" version="4.2.0" targetFramework="net472" />
<package id="Unosquare.Swan.Lite" version="1.3.0" targetFramework="net472" />
</packages>

View file

@ -1,2 +0,0 @@
# HiddenSounds
Fan site for Hidden Sounds

View file

@ -1,5 +0,0 @@
---
name: Artist1
position: Singer
---
Test artist

View file

@ -1,6 +0,0 @@
---
short_name: test
name: Test
position: Producer
---
Test artist

View file

@ -1,16 +0,0 @@
collections:
artists:
output: true
defaults:
- scope:
path: ""
type: "artists"
values:
layout: "artist"
- scope:
path: ""
values:
layout: "default"
baseurl: /HiddenSounds

View file

@ -1,12 +0,0 @@
[
{
"artist": "Artist1",
"title": "Title1",
"url": "https://spotify.com/"
},
{
"artist": "Artist2",
"title": "Title2",
"url": "https://spotify.com/"
}
]

View file

@ -1,16 +0,0 @@
---
layout: default
title: page.name
---
<h1>{{ page.name }}</h1>
<h2>{{ page.position }}</h2>
{{ content }}
<h2>Songs</h2>
<ul>
{% assign filtered_songs = site.data.songs | where: 'artist', page.name %}
{% for song in filtered_songs %}
<li><a href="{{ song.url }}">{{ song.artist }} - {{ song.title }}</a></li>
{% endfor %}
</ul>

View file

@ -1,27 +0,0 @@
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title>{{ page.title }} - HS Fanpage</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="icon.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
<meta name="theme-color" content="#fafafa">
</head>
<body>
<div class="bg-image"></div>
<!--[if IE]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
<![endif]-->
{{ content }}
</body>
</html>

View file

@ -1,14 +0,0 @@
---
title: Artists
---
<h1>Artists</h1>
<ul>
{% for artist in site.artists %}
<li>
<h2>{{ artist.name }}</h2>
<h3>{{ artist.position }}</h3>
<p>{{ artist.content | markdownify }}</p>
</li>
{% endfor %}
</ul>

BIN
bg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 MiB

View file

@ -1,44 +0,0 @@
body {
background-color: #003239;
color: aqua;
}
.bg-image {
/*background-image: url("../HS.png");*/
background-image: url("../bg.png"), linear-gradient(to bottom, #1d1d1d, #1d1d1d, #243537, #009a9a);
/*#727272);*/
background-size: cover;
filter: blur(16px);
height: 100%;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: -1;
margin: 0;
padding: 0;
}
#popularSongs, #hiddenSongs {
width: 40%;
margin: 4%;
border: 1px #78ffee solid;
}
#popularSongs h2, #hiddenSongs h2 {
text-align: center;
color: aqua;
}
#popularSongs {
float: left;
}
#hiddenSongs {
float: right;
}
h1 {
text-align: center;
}

View file

@ -1,15 +0,0 @@
# humanstxt.org/
# The humans responsible & technology colophon
# TEAM
<name> -- <role> -- <twitter>
# THANKS
<name>
# TECHNOLOGY COLOPHON
CSS3, HTML5
Apache Server Configs, jQuery, Modernizr, Normalize.css

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -1,33 +0,0 @@
---
layout: default
title: Hidden Sounds
---
<h1>Hidden Sounds Unofficial (Fan) Website</h1>
<div id="popularSongs">
<h2>Popular Songs</h2>
<div id="popularContainer">
{% for song in site.data.songs %}
<div class="song">
<p>
{% assign artist = site.artists | where: 'name', song.artist | first %}
{% if artist %}
<a href="{{ artist.url | prepend: site.baseurl }}">{{ artist.name }}</a>
{% else %}
{{ song.artist }}
{% endif %}
- <a href="https://spotify.com/">{{ song.title }}</a>
</p>
</div>
{% endfor %}
</div>
</div>
<div id="hiddenSongs">
<h2>Hidden Songs</h2>
<div id="hiddenContainer">
{% for song in site.data.songs %}
<div class="song">
<p><a href="https://spotify.com/">Artist - Title</a></p>
</div>
{% endfor %}
</div>
</div>

View file

@ -1,5 +0,0 @@
# www.robotstxt.org/
# Allow crawling of all content
User-agent: *
Disallow: