Created
December 30, 2025 19:02
-
-
Save gkbrk/445929a854051203ee31afc7495c5a87 to your computer and use it in GitHub Desktop.
Scripts from the hotel music article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import struct | |
| import sys | |
| s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) | |
| s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
| s.bind(('', 2046)) | |
| mreq = struct.pack("4sl", socket.inet_aton("234.0.0.2"), socket.INADDR_ANY) | |
| s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) | |
| while True: | |
| data = s.recv(2048) | |
| sys.stdout.buffer.write(data[8:]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import socket | |
| import struct | |
| import time | |
| import sys | |
| s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) | |
| s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) | |
| file_name = sys.argv[1] | |
| with open(file_name, "rb") as mp3file: | |
| while True: | |
| time.sleep(0.01) | |
| d = mp3file.read(626) | |
| if len(d) == 0: | |
| break | |
| data = b"\x02\xffA\x00\x88\xdfT\x02" + d | |
| s.sendto(data, ("234.0.0.2", 2046)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment