Skip to content

Instantly share code, notes, and snippets.

@Sarverott
Last active August 21, 2025 08:47
Show Gist options
  • Save Sarverott/471b9cbf53da49fbf3ccdefdd89da9be to your computer and use it in GitHub Desktop.
Save Sarverott/471b9cbf53da49fbf3ccdefdd89da9be to your computer and use it in GitHub Desktop.
from gtts import gTTS
import os
import sys
import subprocess
from threading import Thread
import random
import json
def pathTo(*item):
item=list(item)
item.insert(0, os.path.dirname(__file__))
return os.path.join(*item)
def playAudioByTerminal(audiopath, method="ffplay"):
audiopath=json.dumps(audiopath)
commandBank={
'ffplay':f'ffplay -nodisp -autoexit {audiopath}',
#'mplayer':f'mplayer --vo=null {audiopath}',
'aplay':f'aplay {audiopath}',
'nvlc':f'nvlc --no-loop --play-and-exit {audiopath}',
'mpv':f'mpv --no-video {audiopath}',
'play':f'play {audiopath}'
}
if method in commandBank:
os.system(commandBank[method])
else:
raise NameError("method unknow: "+method)
class RadioPlayer:
def playStaticAudio(self, *audioTracker):
audiopath=self.pathToResources('static-audio-samples', ".".join(audioTracker))
if os.path.exists(audiopath):
playAudioByTerminal(audiopath)
def pathToResources(self, *items):
return pathTo('..', 'resources', *items)
def playVoice(self, dialog, index):
self.playStaticAudio(dialog, "voice", str(index), "mp3")
def playTextAd(self, adContent):
lectorAdvertiser=gTTS(text=adContent, lang="pl", slow=False)
lectorAdvertiser.save(self.pathToResources("tmp-sounds", "losie.mp3"))
i=random.randint(1,4)
self.playVoice("begin-ad", i)
playAudioByTerminal(self.pathToResources("tmp-sounds", "losie.mp3"))
self.playVoice("end-ad", i)
x=RadioPlayer()
x.playTextAd(reklama)

radio-cat-music

simple idea but also hard work to do and harsh road before achieving any goal as usual because of human factor


into Almanac of apocaliptical prevention guidelines as mentioned with reverse referencing entry:

  • plan A: radio for independent people that lives among net
    • fails if humans fails by glutony
  • plan B: automated radio platform for one-person-army orchestration
    • fails if humans becomes extremely hostile
  • plan C: crucade by enforcing regret notifying stream to warn and teach that you all live with consequences of your own sin list you stupid humanoids
    • override fail with recall of infinitelly looped punnishing by period of silent passiveness without actions while ragnarok extinction event and restart updated plan C
import os
PATH={
"from":"static-audio-samples/announce-ad",
"to":"static-audio-samples"
}
PREFIX={
"intro-":"begin-ad.voice",
"outro-":"end-ad.voice"
}
def moveDirContent(fromDir, toDir, conditPrefixChanges={}):
audioDir=os.listdir(fromDir)
changeLog={}
for filename in audioDir:
oldpath=fromDir+"/"+filename
if not os.path.isfile(oldpath):
continue
for startPhrase in conditPrefixChanges:
if filename.startswith(startPhrase):
namesplit=filename.split(".")
namesplit[0]=conditPrefixChanges[startPhrase]
filename=".".join(namesplit)
break
newPath=toDir+"/"+filename
changeLog[oldpath]=newPath
os.rename(oldpath, newPath)
return changeLog
#moveDirContent(PATH["from"], PATH["to"], PREFIX)
python -m venv venv/radio-cat-music
source venv/radio-cat-music/bin/activate
python -m pip install gTTS pytube ffmpeg-python discord.py twitchAPI tensorflow
npm install
#sudo apt install ffplay aplay nvlc mpv
#mkdir downloads
#git clone https://github.com/obsproject/obs-studio.git
#wget
podkłady pod ogłoszenia i czytanie nazwy:
koty z ferajny (top cat): intro --- https://youtu.be/6fvhLrBrPQI
wilk i zając: intro wolniejsze --- https://youtu.be/2pzhSDut2QU
wilk i zając: intro --- https://youtu.be/TC4LnHh2yp4?t=111
miami vice: intro --- https://youtu.be/_UmOY6ek_Y4
A my nie chcemy uciekać stąd - Strachy Na Lachy cover :solo na flecie (całość spoko by byłą ale taki pierwszy pomysł był) --- https://youtu.be/QCX80ICtuRQ?t=40
// https://pixabay.com/music/search/?order=ec
const DELAY_BETWEEN_CLICKS=1000;
function extractArtists(downloadButton){
var thisArtistDiv=downloadButton
for(var i=0;i<5;i++){
thisArtistDiv=thisArtistDiv.parentElement;
}
var trackInfo=thisArtistDiv.querySelectorAll("a");
return {
trackName:thisArtistDiv.querySelectorAll("a")[1].innerText,
trackLink:thisArtistDiv.querySelectorAll("a")[1].href,
artistName:thisArtistDiv.querySelectorAll("a")[0].innerText,
artistLink:thisArtistDiv.querySelectorAll("a")[0].href,
downloadButtonHook:downloadButton
};
}
var trackMap = Array.from(
document.querySelectorAll("button>span>span")
).filter(
(downloadSuspect)=>downloadSuspect.innerText=="Download"
).map(extractArtists);
function nextTrackClick(){
if(!this.hasOwnProperty("nextTrackClickCounter")){
this.nextTrackClickCounter=0;
}
if(this.nextTrackClickCounter<trackMap.length){
load=trackMap[this.nextTrackClickCounter];
console.log(`---# ${load.artistName} - ${load.trackName}
user: ${load.artistLink}
link: ${load.trackLink}`
);
load.downloadButtonHook.click();
this.nextTrackClickCounter++;
}else{
clearInterval(this);
//
}
}
console.log("> ",window.location.href);
setInterval(nextTrackClick, DELAY_BETWEEN_CLICKS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment