Example #1
0
    def get(self):
        # args = self.parser.parse_args()
        # print(args)

        chunk = self.fetch()
        song = AudioSegment.from_file(io.BytesIO(chunk), format="mp3").export(
            "/home/app/SuperCollider/file_1.wav", format="wav")

        client = pyOSC3.OSCClient()
        client.connect(('192.168.208.3', 57120))
        msg = pyOSC3.OSCMessage()
        msg.setAddress("/print")
        msg.append("/home/sclang/.local/share/SuperCollider/file_1.wav")
        client.send(msg)

        return None
Example #2
0
    def populate_queue():
        """
        Random station playback
        """

        client = pyOSC3.OSCClient()
        client.connect(('10.5.0.11', 57120))

        msg = pyOSC3.OSCMessage()
        msg.setAddress("/stop")
        msg.append('stopping')
        client.send(msg)

        res = StreamingAuto.get_last()
        res_user = StreamingUser.get_last()

        if not res_user:
            radio = res.url
            name = res.name
            country = res.country
            place_name = res.place_name

        else:
            radio = res_user.url
            name = res_user.name
            country = res_user.country
            place_name = res_user.place_name

            StreamingUser.query.filter(StreamingUser.name == name).delete()

        msg = pyOSC3.OSCMessage()
        msg.setAddress("/start")
        msg.append(radio)
        msg.append(np.random.exponential())

        chunk = check_health(radio)
        song = AudioSegment.from_file(io.BytesIO(chunk), format="mp3")
        song.export("SuperCollider/out.wav", format="wav")

        f = open("SuperCollider/out.txt", "w")
        f.write(name)
        f.close()

        client.send(msg)

        if not res_user:
            jsonObj = {"msg": "{0} {1} {2}".format(
                res.country, res.place_name, res.name)}
        else:
            jsonObj = {"msg": "{0} {1} {2}".format(
                res_user.country, res_user.place_name, res_user.name)}

        # sleeping so backend and sc can 'sync'
        time.sleep(5)
        s = NowPlaying(country=str(country), place_name=str(place_name),
                       name=str(name), url=str(radio),
                       timestamp=datetime.now().strftime('%Y-%m-%d %H:%M:%S'))

        db.session.add(s)
        db.session.flush()
        db.session.commit()
        return jsonObj
Example #3
0
 def __init__(self):
     ip, port = config["ip"], config["port"]
     self.lock = threading.Lock()
     self.client = pyOSC3.OSCClient()
     self.client.connect((ip, port))