Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maciekt07/spotifyadblock
Adblock+ Now Playing for Spotify (for research purposes only plz dont sue me)
https://github.com/maciekt07/spotifyadblock
advertisement console-app console-application csharp delay dotnet now-playing process process-manager processes spotify spotify-api spotify-free spotify-freemium task-manager while while-loop windows
Last synced: about 2 months ago
JSON representation
Adblock+ Now Playing for Spotify (for research purposes only plz dont sue me)
- Host: GitHub
- URL: https://github.com/maciekt07/spotifyadblock
- Owner: maciekt07
- License: mit
- Created: 2021-10-31T18:44:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-18T12:45:45.000Z (about 3 years ago)
- Last Synced: 2023-02-26T22:22:07.925Z (almost 2 years ago)
- Topics: advertisement, console-app, console-application, csharp, delay, dotnet, now-playing, process, process-manager, processes, spotify, spotify-api, spotify-free, spotify-freemium, task-manager, while, while-loop, windows
- Language: C#
- Homepage:
- Size: 468 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SpotifyAdBlock
Get currently played Spotify song name and block ads by using C# console app / Get processes by name method
![preview](https://raw.githubusercontent.com/maciekkoks/SpotifyBlockAds/main/img/app-preview1.png)
# Ads skipping
![ads](https://raw.githubusercontent.com/maciekkoks/SpotifyBlockAds/main/img/ads-skip.png)
# Memory Usage
![memory](https://raw.githubusercontent.com/maciekkoks/SpotifyBlockAds/main/img/memory-usage.png)# Main C# Code
```cs
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;namespace SpotifyNowPlaying
{
class Program
{
[DllImport("user32.dll")]public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo);
public static int a = 0;
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Spotify AdBlocker + Now Playing");
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("Author: github.com/maciekkoks");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine();while (true)
{
Console.ForegroundColor = ConsoleColor.White;
var proc = Process.GetProcessesByName("Spotify").LastOrDefault(p => !string.IsNullOrWhiteSpace(p.MainWindowTitle));
if (proc == null)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Spotify is not running");
System.Diagnostics.Process.Start("Spotify.exe");
Console.ResetColor();
Thread.Sleep(1000);
continue;
}
if (proc.MainWindowTitle == "Advertisement" || proc.MainWindowTitle == "Spotify")
{
foreach (var process in Process.GetProcessesByName("Spotify"))
{
process.Kill();
}
System.Diagnostics.Process.Start("Spotify.exe");
Thread.Sleep(2000);
keybd_event(0xB3, 0, 1, IntPtr.Zero);
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Advertisement skipped");
a++;
Console.ResetColor();
while (proc.MainWindowTitle == "Spotify"){Thread.Sleep(1000);}
}
if (proc != null)
{
if (proc.MainWindowTitle != "Spotify Free")
{
Console.Title = " Spotify AdBlocker - " + "Advertisements skipped: " + a + " " + proc.MainWindowTitle;
Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + "] " + proc.MainWindowTitle);
}
else
{
Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + "] " + "Spotify (Paused)");
Console.Title = " Spotify AdBlocker - " + "Advertisements skipped: " + a + " " + "Spotify (Paused)";
}
Thread.Sleep(1000);
}
}
}
}
}
```