Skip to content

Instantly share code, notes, and snippets.

@kingosticks
kingosticks / playbin.rs
Last active May 30, 2022 12:33
Using source-setup with spotifyaudiosrc
use gst::glib;
use gst::prelude::*;
use gst::gst_info;
use anyhow::{Error};
use std::env;
use once_cell::sync::Lazy;
album: Using release-id: 9cbd294c-2979-49e8-8c48-210c3fb983e3
Updating art to /var/lib/mopidy/pidi/UGVhY2ggUGl0X0JlaW5nIFNvIE5vcm1hbA==.jpg
ERROR Fetching https://auth.mopidy.com/spotify/token failed: ('Connection aborted.', error("(110, 'ETIMEDOUT')",))
ERROR Triggering event failed: track_playback_started(tl_track)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mopidy/listener.py", line 45, in on_event
getattr(self, event)(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/mopidy_pidi/frontend.py", line 87, in track_playback_started
self.update_track(tl_track.track, 0)
File "/usr/local/lib/python2.7/dist-packages/mopidy_pidi/frontend.py", line 115, in update_track
album: Using release-id: 5ad8e964-5d1a-4c10-be08-865ed9809dc2
Exception in thread Thread-43:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/mopidy_pidi/brainz.py", line 56, in async_request_album_art
self.save_album_art(album_art, file_name)
File "/usr/local/lib/python2.7/dist-packages/mopidy_pidi/brainz.py", line 85, in save_album_art
@kingosticks
kingosticks / scan.py
Last active September 19, 2019 22:59
File scanner using Gst discoverer
from __future__ import (
absolute_import, division, print_function, unicode_literals)
import collections
import logging
import time
from mopidy import exceptions
from mopidy.audio import tags as tags_lib, utils
from mopidy.internal import encoding, log
@kingosticks
kingosticks / gist:a87fb2ae9dea12b534ef170e8551bc76
Created January 24, 2019 10:34
Spotify Connect Queue HTTP endpoint
curl -X "PUT" "https://spclient.wg.spotify.com/connect-state/v1/devices/hobs_12918ba3947cfbc0ccf015710a7063e6bcf" \
--data "{\"member_type\":\"CONNECT_STATE\"}" \
-H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer <SOME_AUTH>" \
-H "x-spotify-connection-id: <SOME_CONNECTION_ID>"
@kingosticks
kingosticks / gist:970886f978ba1bbe180927db1ab6fae9
Created January 2, 2019 23:58
spotify-analyze /proc/?/map
Previously (16.04):
00400000-02bdc000 r-xp 00000000 103:05 3411267 /usr/share/spotify/spotify
02bdd000-02bdf000 r--p 027dc000 103:05 3411267 /usr/share/spotify/spotify
02bdf000-02fe8000 rwxp 027de000 103:05 3411267 /usr/share/spotify/spotify
Now (18.10):
00200000-010ed000 r--p 00000000 103:06 4471655 /usr/share/spotify/spotify
010ed000-021e1000 r-xp 00eed000 103:06 4471655 /usr/share/spotify/spotify
021e1000-025f5000 rwxp 01fe1000 103:06 4471655 /usr/share/spotify/spotify
@kingosticks
kingosticks / search_youtube.py
Created May 23, 2018 15:02
Parses YouTube's mobile search results page
#!/usr/bin/python
from __future__ import unicode_literals
from lxml import html
import requests
import sys
if len(sys.argv) > 1:
query = sys.argv[1]
else:
@kingosticks
kingosticks / mopidy-display-cover.sh
Last active November 9, 2020 14:53
Mopidy cover artwork displayer
#!/bin/bash
# sudo apt-get install mpc jq fbi wget
MPD_PORT=6600
HTTP_PORT=6680
RPC_HOST=http://localhost:$HTTP_PORT/mopidy/rpc
TRACK_ARTWORK=/tmp/cover-art-img
DEFAULT_ARTWORK=some-default-picture
# In mopidy/mpd/actor.py
class MpdFrontend(pykka.ThreadingActor, CoreListener):
def __init__(self, config, core):
super(MpdFrontend, self).__init__()
self.hostname = network.format_hostname(config['mpd']['hostname'])
self.port = config['mpd']['port']
self.uri_map = uri_mapper.MpdUriMapper(core)

Keybase proof

I hereby claim:

  • I am kingosticks on github.
  • I am nicksteel (https://keybase.io/nicksteel) on keybase.
  • I have a public key ASAI609fqxbBD_x3OGzskhEOfq1gOVeRRJOO5NkvGzFMVQo

To claim this, I am signing this object: