[OPEN-SOURCE] SpotifyOthers

Free [OPEN-SOURCE] SpotifyOthers 7.11717

SpotifyOthers is minimalistic tool for exporting current song from Spotify to text file.


Virustotal can be found HERE

I made this tool because there was non-available at the time. This does not request any action from user, just running it and leaving it to background. There will be current_song.txt in root of the software, use this with OBS.

It only works for Windows Spotify -client and there should be no difference what version of Spotify you are using, as they use software title to display current track.

Those who have any knowledge in C# can easily get YouTube, iTunes and various other media players to work.

Source code:
Code:
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace SpotifyOthers {
    internal class Program {
        private static byte[] LastBuffer { get; set; }

        private static void WriteToFile(byte[] buffer) {
            if (buffer == null || buffer == LastBuffer) return;
            var hwid = File.Create("current_song.txt").SafeFileHandle;
            if (hwid == null) return;
            using (var stream = new FileStream(hwid, FileAccess.Write)) {
                if (buffer != LastBuffer) stream.Write(buffer, 0, buffer.Length);
            }
            LastBuffer = buffer;
        }

        private static string GetMediaPlayers() {
            var processes = Process.GetProcesses();
            var buffer = processes.FirstOrDefault(p => p.ProcessName.ToLower() == "spotify" &&
                                                       !string.IsNullOrEmpty(p.MainWindowTitle) &&
                                                       p.MainWindowTitle.ToLower() != "spotify");
            return buffer?.MainWindowTitle;
        }

        private static void Main(string[] args) {
            while (true) {
                WriteToFile(Encoding.UTF8.GetBytes($"Currently Playing: {GetMediaPlayers()}"));
                Thread.Sleep(10000);
            }
        }
    }
}

There will be no updates to this software, only hotfixes to base code if needed.
Author
SmokingYoda
Downloads
1,583
Views
1,612
First release
Last update
Rating
5.00 star(s) 2 ratings
Top