Merge pull request #52 from BafDyce/upstream-changes
Merge upstream changes
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[submodule "pymumble"]
 | 
					[submodule "pymumble"]
 | 
				
			||||||
	path = pymumble
 | 
						path = pymumble
 | 
				
			||||||
	url = https://github.com/azlux/pymumble
 | 
						url = git://github.com/azlux/pymumble.git
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										24
									
								
								README.fr.md
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								README.fr.md
									
									
									
									
									
								
							@@ -1,24 +0,0 @@
 | 
				
			|||||||
# botamusique
 | 
					 | 
				
			||||||
[English Version](README.md)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
======
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
##FR:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Botamusique est un bot pour mumble qui a pour vocation de permettre aux utillisateurs d'<27>couter de la musique ensemble via sa sortie son.
 | 
					 | 
				
			||||||
Les fonctionnalit<69>s pr<70>vues sont celles qu'on attend d'un lecteur de musique classique (Musique suivante, pr<70>c<EFBFBD>dente, al<61>atoire, lecture d'un repertoire)
 | 
					 | 
				
			||||||
Pour ceci il va chercher les musiques t<>l<EFBFBD>charg<72>es par les utillisateurs dans un dossier.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#### Commandes
 | 
					 | 
				
			||||||
- [ ] list
 | 
					 | 
				
			||||||
- [ ] play
 | 
					 | 
				
			||||||
- [ ] playfolder
 | 
					 | 
				
			||||||
- [ ] list
 | 
					 | 
				
			||||||
- [ ] random
 | 
					 | 
				
			||||||
- [ ] volume
 | 
					 | 
				
			||||||
- [ ] skip
 | 
					 | 
				
			||||||
- [ ] stop
 | 
					 | 
				
			||||||
- [ ] joinme
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#### Futur proche
 | 
					 | 
				
			||||||
A terme une interface web sera ajout<75>e pour faciliter son utillisation.
 | 
					 | 
				
			||||||
							
								
								
									
										45
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								README.md
									
									
									
									
									
								
							@@ -19,7 +19,13 @@ Note that the ToDo list at the end of the Readme is **outdated** and **not appli
 | 
				
			|||||||
Botamusique is a mumble bot which goal is to allow users to listen music together with its audio output.
 | 
					Botamusique is a mumble bot which goal is to allow users to listen music together with its audio output.
 | 
				
			||||||
Predicted functionnalities will be the one you could expect from any classic music player.
 | 
					Predicted functionnalities will be the one you could expect from any classic music player.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1. Where to start
 | 
					Bot the can play :
 | 
				
			||||||
 | 
					- Radio url
 | 
				
			||||||
 | 
					- Youtube/Soundcloud URL (everything supported by youtube-dl)
 | 
				
			||||||
 | 
					- Local folder (disabled, I need to work on the web interface)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#### Web interface
 | 
				
			||||||
 | 
					* Disable * I need to work on it. Since I use this bot for radio, youtube/soundcloud and folder music, the web interace isn't ready.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You need to create a folder for all your music. Organize your music by subfolder.
 | 
					You need to create a folder for all your music. Organize your music by subfolder.
 | 
				
			||||||
The main folder need to be declare into the config (with a '/' at the end)
 | 
					The main folder need to be declare into the config (with a '/' at the end)
 | 
				
			||||||
@@ -30,46 +36,23 @@ The main folder need to be declare into the config (with a '/' at the end)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
commands (don't forget the sudo mode):
 | 
					commands (don't forget the sudo mode):
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
apt-get install python3-pip
 | 
					apt install python3-pip
 | 
				
			||||||
pip3 install opuslib
 | 
					apt install ffmpeg
 | 
				
			||||||
pip3 install protobuf
 | 
					apt install youtube-dl
 | 
				
			||||||
pip3 install flask
 | 
					 | 
				
			||||||
apt-get install ffmpeg
 | 
					 | 
				
			||||||
git clone --recurse-submodules https://github.com/azlux/botamusique.git
 | 
					git clone --recurse-submodules https://github.com/azlux/botamusique.git
 | 
				
			||||||
cd ./botamusique
 | 
					cd ./botamusique
 | 
				
			||||||
 | 
					pip3 install -r requirements.txt
 | 
				
			||||||
chmod +x ./mumbleBot.py
 | 
					chmod +x ./mumbleBot.py
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Starting the bot
 | 
					#### Starting the bot
 | 
				
			||||||
./mumbleBot.py -s HOST -u BOTNAME -P PASSWORD -p PORT -c CHANNEL
 | 
					`./mumbleBot.py -s HOST -u BOTNAME -P PASSWORD -p PORT -c CHANNEL`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The bot listen to the 8181 port so you should redirect to this one in you NAT configuration to let others peoples access the web interface.
 | 
					The bot listen to the 8181 port so you should redirect to this one in you NAT configuration to let others peoples access the web interface. (DISABLED)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.TODO list
 | 
					2.TODO list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### TODOLIST
 | 
					### TODOLIST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Features
 | 
					Check the issue #3
 | 
				
			||||||
- [ ] Next song
 | 
					 | 
				
			||||||
- [ ] Previous song
 | 
					 | 
				
			||||||
- [x] Randomizer
 | 
					 | 
				
			||||||
- [ ] Looking for songs previously downloaded in a folder by users.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#### Commands with the interface
 | 
					 | 
				
			||||||
- [x] list
 | 
					 | 
				
			||||||
- [x] play
 | 
					 | 
				
			||||||
- [x] playfolder
 | 
					 | 
				
			||||||
- [x] random
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#### Commands by message to the bot
 | 
					 | 
				
			||||||
- [x] volume
 | 
					 | 
				
			||||||
- [ ] skip
 | 
					 | 
				
			||||||
- [x] stop
 | 
					 | 
				
			||||||
- [x] joinme
 | 
					 | 
				
			||||||
- [x] away
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#### Web Interface
 | 
					 | 
				
			||||||
- [x] Primary functions
 | 
					 | 
				
			||||||
- [ ] CSS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,16 +1,13 @@
 | 
				
			|||||||
[bot]
 | 
					[bot]
 | 
				
			||||||
comment = Coucou, Je suis née du savoir du Azlux, accès au https://azlux.fr/bot
 | 
					comment = Coucou, Je suis née du savoir du Azlux, accès au https://azlux.fr/bot
 | 
				
			||||||
volume = 0.1
 | 
					volume = 0.1
 | 
				
			||||||
admin = BafTac
 | 
					admin = Azlux;AzMobile
 | 
				
			||||||
music_folder = /home/fabian/music/mumblebot/
 | 
					music_folder = /home/dmichel/botamusique/music/
 | 
				
			||||||
tmp_folder = /tmp/
 | 
					tmp_folder = /tmp/
 | 
				
			||||||
 | 
					web_interface = False
 | 
				
			||||||
 | 
					is_web_proxified = True
 | 
				
			||||||
ignored_folders = tmp
 | 
					ignored_folders = tmp
 | 
				
			||||||
ignored_files = Thumbs.db
 | 
					ignored_files = Thumbs.db
 | 
				
			||||||
is_proxified = True
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[debug]
 | 
					 | 
				
			||||||
ffmpeg = False
 | 
					 | 
				
			||||||
mumbleConnection = False
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[command]
 | 
					[command]
 | 
				
			||||||
play_file = file
 | 
					play_file = file
 | 
				
			||||||
@@ -28,6 +25,12 @@ stop_and_getout = oust
 | 
				
			|||||||
joinme = joinme
 | 
					joinme = joinme
 | 
				
			||||||
queue = queue
 | 
					queue = queue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[radio]
 | 
				
			||||||
 | 
					ponyville = http://192.99.131.205:8000/stream.mp3
 | 
				
			||||||
 | 
					luna = http://radio.ponyvillelive.com:8002/stream
 | 
				
			||||||
 | 
					radiobrony = http://62.210.138.34:8000/live
 | 
				
			||||||
 | 
					celestiaradio = http://celestia.aiverse.org:8000/mp3_256
 | 
				
			||||||
 | 
					jazz = http://jazz-wr04.ice.infomaniak.ch/jazz-wr04-128.mp3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[strings]
 | 
					[strings]
 | 
				
			||||||
current_volume = volume : %d%%
 | 
					current_volume = volume : %d%%
 | 
				
			||||||
@@ -40,7 +43,7 @@ no_file = Not file here
 | 
				
			|||||||
bad_url = Bad URL asked
 | 
					bad_url = Bad URL asked
 | 
				
			||||||
multiple_matches = Track not found! Possible candidates:
 | 
					multiple_matches = Track not found! Possible candidates:
 | 
				
			||||||
queue_contents = The next items in the queue are:
 | 
					queue_contents = The next items in the queue are:
 | 
				
			||||||
queue_empty = The queue is empty!
 | 
					queue_empty = No more music in the playlist!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
help = Command available:
 | 
					help = Command available:
 | 
				
			||||||
       <br />!play_file <path>
 | 
					       <br />!play_file <path>
 | 
				
			||||||
@@ -53,3 +56,7 @@ help = Command available:
 | 
				
			|||||||
       <br />!oust - stop + Go to default channel
 | 
					       <br />!oust - stop + Go to default channel
 | 
				
			||||||
       <br />!v - get or change the volume (in %)
 | 
					       <br />!v - get or change the volume (in %)
 | 
				
			||||||
       <br />!joinme
 | 
					       <br />!joinme
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[debug]
 | 
				
			||||||
 | 
					ffmpeg = False
 | 
				
			||||||
 | 
					mumbleConnection = False
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								interface.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								interface.py
									
									
									
									
									
								
							@@ -70,7 +70,8 @@ def index():
 | 
				
			|||||||
        if 'add_file' in request.form and ".." not in request.form['add_file']:
 | 
					        if 'add_file' in request.form and ".." not in request.form['add_file']:
 | 
				
			||||||
            item = ('file', request.form['add_file'])
 | 
					            item = ('file', request.form['add_file'])
 | 
				
			||||||
            var.playlist.append(item)
 | 
					            var.playlist.append(item)
 | 
				
			||||||
        if ('add_folder' in request.form and ".." not in request.form['add_folder']) or ('add_folder_recursively' in request.form and ".." not in request.form['add_folder_recursively']) :
 | 
					
 | 
				
			||||||
 | 
					        elif ('add_folder' in request.form and ".." not in request.form['add_folder']) or ('add_folder_recursively' in request.form and ".." not in request.form['add_folder_recursively']) :
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                folder = request.form['add_folder']
 | 
					                folder = request.form['add_folder']
 | 
				
			||||||
            except:
 | 
					            except:
 | 
				
			||||||
@@ -93,15 +94,23 @@ def index():
 | 
				
			|||||||
            ))
 | 
					            ))
 | 
				
			||||||
            print('Adding to playlist: ', files)
 | 
					            print('Adding to playlist: ', files)
 | 
				
			||||||
            var.playlist.extend(files)
 | 
					            var.playlist.extend(files)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        elif 'add_url' in request.form :
 | 
				
			||||||
 | 
					            var.playlist.append(['url', request.form['add_url']])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        elif 'add_radio' in request.form:
 | 
				
			||||||
 | 
					            var.playlist.append(['radio', request.form['add_radio']])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        elif 'delete_music' in request.form:
 | 
					        elif 'delete_music' in request.form:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                var.playlist.remove("file", request.form['delete_music'])
 | 
					                var.playlist.remove(["file", request.form['delete_music']])
 | 
				
			||||||
            except ValueError:
 | 
					            except ValueError:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
        elif 'action' in request.form:
 | 
					        elif 'action' in request.form:
 | 
				
			||||||
            action = request.form['action']
 | 
					            action = request.form['action']
 | 
				
			||||||
            if action == "randomize":
 | 
					            if action == "randomize":
 | 
				
			||||||
                random.shuffle(var.playlist)
 | 
					                random.shuffle(var.playlist)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if var.current_music:
 | 
					    if var.current_music:
 | 
				
			||||||
        source = var.current_music[0]
 | 
					        source = var.current_music[0]
 | 
				
			||||||
        # format for current_music below:
 | 
					        # format for current_music below:
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								media.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								media.py
									
									
									
									
									
								
							@@ -18,7 +18,7 @@ def get_radio_server_description(url):
 | 
				
			|||||||
        response = urllib.request.urlopen(request)
 | 
					        response = urllib.request.urlopen(request)
 | 
				
			||||||
        data = json.loads(response.read().decode("utf-8"))
 | 
					        data = json.loads(response.read().decode("utf-8"))
 | 
				
			||||||
        title_server = data['servertitle']
 | 
					        title_server = data['servertitle']
 | 
				
			||||||
        logging.debug("TITLE FOUND SHOUTCAST: " + title_server)
 | 
					        logging.info("TITLE FOUND SHOUTCAST: " + title_server)
 | 
				
			||||||
    except urllib.error.HTTPError:
 | 
					    except urllib.error.HTTPError:
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
    except http.client.BadStatusLine:
 | 
					    except http.client.BadStatusLine:
 | 
				
			||||||
@@ -32,7 +32,7 @@ def get_radio_server_description(url):
 | 
				
			|||||||
            response = urllib.request.urlopen(request)
 | 
					            response = urllib.request.urlopen(request)
 | 
				
			||||||
            data = json.loads(response.read().decode('utf-8', errors='ignore'), strict=False)
 | 
					            data = json.loads(response.read().decode('utf-8', errors='ignore'), strict=False)
 | 
				
			||||||
            title_server = data['icestats']['source'][0]['server_name'] + ' - ' + data['icestats']['source'][0]['server_description']
 | 
					            title_server = data['icestats']['source'][0]['server_name'] + ' - ' + data['icestats']['source'][0]['server_description']
 | 
				
			||||||
            logging.debug("TITLE FOUND ICECAST: " + title_server)
 | 
					            logging.info("TITLE FOUND ICECAST: " + title_server)
 | 
				
			||||||
            if not title_server:
 | 
					            if not title_server:
 | 
				
			||||||
                title_server = url
 | 
					                title_server = url
 | 
				
			||||||
        except urllib.error.URLError:
 | 
					        except urllib.error.URLError:
 | 
				
			||||||
@@ -55,7 +55,7 @@ def get_radio_title(url):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            metadata_length = struct.unpack('B', response.read(1))[0] * 16  # length byte
 | 
					            metadata_length = struct.unpack('B', response.read(1))[0] * 16  # length byte
 | 
				
			||||||
            metadata = response.read(metadata_length).rstrip(b'\0')
 | 
					            metadata = response.read(metadata_length).rstrip(b'\0')
 | 
				
			||||||
            logging.debug(metadata)
 | 
					            logging.info(metadata)
 | 
				
			||||||
            # extract title from the metadata
 | 
					            # extract title from the metadata
 | 
				
			||||||
            m = re.search(br"StreamTitle='([^']*)';", metadata)
 | 
					            m = re.search(br"StreamTitle='([^']*)';", metadata)
 | 
				
			||||||
            if m:
 | 
					            if m:
 | 
				
			||||||
@@ -65,3 +65,14 @@ def get_radio_title(url):
 | 
				
			|||||||
    except (urllib.error.URLError, urllib.error.HTTPError):
 | 
					    except (urllib.error.URLError, urllib.error.HTTPError):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
    return 'Impossible to get the music title'
 | 
					    return 'Impossible to get the music title'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_url(string):
 | 
				
			||||||
 | 
					    if string.startswith('http'):
 | 
				
			||||||
 | 
					        return string
 | 
				
			||||||
 | 
					    p = re.compile('href="(.+)"', re.IGNORECASE)
 | 
				
			||||||
 | 
					    res = re.search(p, string)
 | 
				
			||||||
 | 
					    if res:
 | 
				
			||||||
 | 
					        return res.group(1)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        return False
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										49
									
								
								mumbleBot.py
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								mumbleBot.py
									
									
									
									
									
								
							@@ -18,6 +18,7 @@ import variables as var
 | 
				
			|||||||
import hashlib
 | 
					import hashlib
 | 
				
			||||||
import youtube_dl
 | 
					import youtube_dl
 | 
				
			||||||
import media
 | 
					import media
 | 
				
			||||||
 | 
					import logging
 | 
				
			||||||
import util
 | 
					import util
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MumbleBot:
 | 
					class MumbleBot:
 | 
				
			||||||
@@ -28,6 +29,12 @@ class MumbleBot:
 | 
				
			|||||||
        self.channel = args.channel
 | 
					        self.channel = args.channel
 | 
				
			||||||
        var.current_music = None
 | 
					        var.current_music = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        FORMAT = '%(asctime)s: %(message)s'
 | 
				
			||||||
 | 
					        if args.quiet:
 | 
				
			||||||
 | 
					            logging.basicConfig(format=FORMAT, level=logging.ERROR, datefmt='%Y-%m-%d %H:%M:%S')
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            logging.basicConfig(format=FORMAT, level=logging.DEBUG, datefmt='%Y-%m-%d %H:%M:%S')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ######
 | 
					        ######
 | 
				
			||||||
        ## Format of the Playlist :
 | 
					        ## Format of the Playlist :
 | 
				
			||||||
        ## [("<type>","<path>")]
 | 
					        ## [("<type>","<path>")]
 | 
				
			||||||
@@ -47,12 +54,12 @@ class MumbleBot:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        var.user = args.user
 | 
					        var.user = args.user
 | 
				
			||||||
        var.music_folder = var.config.get('bot', 'music_folder')
 | 
					        var.music_folder = var.config.get('bot', 'music_folder')
 | 
				
			||||||
        var.is_proxified = var.config.getboolean("bot", "is_proxified")
 | 
					        var.is_proxified = var.config.getboolean("bot", "is_web_proxified")
 | 
				
			||||||
        self.exit = False
 | 
					        self.exit = False
 | 
				
			||||||
        self.nb_exit = 0
 | 
					        self.nb_exit = 0
 | 
				
			||||||
        self.thread = None
 | 
					        self.thread = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if args.wi_addr:
 | 
					        if var.config.getboolean("bot", "web_interface"):
 | 
				
			||||||
            interface.init_proxy()
 | 
					            interface.init_proxy()
 | 
				
			||||||
            tt = threading.Thread(target=start_web_interface, args=(args.wi_addr, args.wi_port))
 | 
					            tt = threading.Thread(target=start_web_interface, args=(args.wi_addr, args.wi_port))
 | 
				
			||||||
            tt.daemon = True
 | 
					            tt.daemon = True
 | 
				
			||||||
@@ -74,11 +81,11 @@ class MumbleBot:
 | 
				
			|||||||
        self.loop()
 | 
					        self.loop()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def ctrl_caught(self, signal, frame):
 | 
					    def ctrl_caught(self, signal, frame):
 | 
				
			||||||
        print("\ndeconnection asked")
 | 
					        logging.info("\ndeconnection asked")
 | 
				
			||||||
        self.exit = True
 | 
					        self.exit = True
 | 
				
			||||||
        self.stop()
 | 
					        self.stop()
 | 
				
			||||||
        if self.nb_exit > 1:
 | 
					        if self.nb_exit > 1:
 | 
				
			||||||
            print("Forced Quit")
 | 
					            logging.info("Forced Quit")
 | 
				
			||||||
            sys.exit(0)
 | 
					            sys.exit(0)
 | 
				
			||||||
        self.nb_exit += 1
 | 
					        self.nb_exit += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -94,7 +101,7 @@ class MumbleBot:
 | 
				
			|||||||
            else:
 | 
					            else:
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            print(command + ' - ' + parameter + ' by ' + self.mumble.users[text.actor]['name'])
 | 
					            logging.info(command + ' - ' + parameter + ' by ' + self.mumble.users[text.actor]['name'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if command == var.config.get('command', 'play_file') and parameter:
 | 
					            if command == var.config.get('command', 'play_file') and parameter:
 | 
				
			||||||
                music_folder = var.config.get('bot', 'music_folder')
 | 
					                music_folder = var.config.get('bot', 'music_folder')
 | 
				
			||||||
@@ -122,6 +129,8 @@ class MumbleBot:
 | 
				
			|||||||
                var.playlist.append(["url", parameter])
 | 
					                var.playlist.append(["url", parameter])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            elif command == var.config.get('command', 'play_radio') and parameter:
 | 
					            elif command == var.config.get('command', 'play_radio') and parameter:
 | 
				
			||||||
 | 
					                if var.config.has_option('radio', parameter):
 | 
				
			||||||
 | 
					                    parameter = var.config.get('radio', parameter)
 | 
				
			||||||
                var.playlist.append(["radio", parameter])
 | 
					                var.playlist.append(["radio", parameter])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            elif command == var.config.get('command', 'help'):
 | 
					            elif command == var.config.get('command', 'help'):
 | 
				
			||||||
@@ -180,9 +189,14 @@ class MumbleBot:
 | 
				
			|||||||
                self.mumble.users[text.actor].send_message(reply)
 | 
					                self.mumble.users[text.actor].send_message(reply)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            elif command == var.config.get('command', 'next'):
 | 
					            elif command == var.config.get('command', 'next'):
 | 
				
			||||||
 | 
					                if var.playlist:
 | 
				
			||||||
                    var.current_music = [var.playlist[0][0], var.playlist[0][1], None, None]
 | 
					                    var.current_music = [var.playlist[0][0], var.playlist[0][1], None, None]
 | 
				
			||||||
                    var.playlist.pop(0)
 | 
					                    var.playlist.pop(0)
 | 
				
			||||||
                    self.launch_next()
 | 
					                    self.launch_next()
 | 
				
			||||||
 | 
					                else:
 | 
				
			||||||
 | 
					                    self.mumble.users[text.actor].send_message(var.config.get('strings', 'queue_empty'))
 | 
				
			||||||
 | 
					                    self.stop()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            elif command == var.config.get('command', 'list'):
 | 
					            elif command == var.config.get('command', 'list'):
 | 
				
			||||||
                folder_path = var.config.get('bot', 'music_folder')
 | 
					                folder_path = var.config.get('bot', 'music_folder')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -226,9 +240,9 @@ class MumbleBot:
 | 
				
			|||||||
        path = ""
 | 
					        path = ""
 | 
				
			||||||
        title = ""
 | 
					        title = ""
 | 
				
			||||||
        if var.current_music[0] == "url":
 | 
					        if var.current_music[0] == "url":
 | 
				
			||||||
            regex = re.compile("<a href=\"(.*?)\"")
 | 
					            url = media.get_url(var.current_music[1])
 | 
				
			||||||
            m = regex.match(var.current_music[1])
 | 
					            if not url:
 | 
				
			||||||
            url = m.group(1)
 | 
					                return
 | 
				
			||||||
            path, title = self.download_music(url)
 | 
					            path, title = self.download_music(url)
 | 
				
			||||||
            var.current_music[1] = url
 | 
					            var.current_music[1] = url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -237,9 +251,9 @@ class MumbleBot:
 | 
				
			|||||||
            title = var.current_music[1]
 | 
					            title = var.current_music[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        elif var.current_music[0] == "radio":
 | 
					        elif var.current_music[0] == "radio":
 | 
				
			||||||
            regex = re.compile("<a href=\"(.*?)\"")
 | 
					            url = media.get_url(var.current_music[1])
 | 
				
			||||||
            m = regex.match(var.current_music[1])
 | 
					            if not url:
 | 
				
			||||||
            url = m.group(1)
 | 
					                return
 | 
				
			||||||
            var.current_music[1] = url
 | 
					            var.current_music[1] = url
 | 
				
			||||||
            path = url
 | 
					            path = url
 | 
				
			||||||
            title = media.get_radio_server_description(url)
 | 
					            title = media.get_radio_server_description(url)
 | 
				
			||||||
@@ -249,7 +263,7 @@ class MumbleBot:
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            ffmpeg_debug = "warning"
 | 
					            ffmpeg_debug = "warning"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        command = ["ffmpeg", '-v', ffmpeg_debug, '-nostdin', '-i', path, '-ac', '1', '-f', 's16le', '-ar', '48000', '-']
 | 
					        command = ["/usr/bin/ffmpeg", '-v', ffmpeg_debug, '-nostdin', '-i', path, '-ac', '1', '-f', 's16le', '-ar', '48000', '-']
 | 
				
			||||||
        self.thread = sp.Popen(command, stdout=sp.PIPE, bufsize=480)
 | 
					        self.thread = sp.Popen(command, stdout=sp.PIPE, bufsize=480)
 | 
				
			||||||
        var.current_music[2] = title
 | 
					        var.current_music[2] = title
 | 
				
			||||||
        var.current_music[3] = path
 | 
					        var.current_music[3] = path
 | 
				
			||||||
@@ -271,9 +285,8 @@ class MumbleBot:
 | 
				
			|||||||
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
 | 
					        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
 | 
				
			||||||
            for i in range(2):
 | 
					            for i in range(2):
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    info_dict = ydl.extract_info(url, download=False)
 | 
					                    info_dict = ydl.extract_info(url)
 | 
				
			||||||
                    video_title = info_dict['title']
 | 
					                    video_title = info_dict['title']
 | 
				
			||||||
                    ydl.download([url])
 | 
					 | 
				
			||||||
                except youtube_dl.utils.DownloadError:
 | 
					                except youtube_dl.utils.DownloadError:
 | 
				
			||||||
                    pass
 | 
					                    pass
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
@@ -295,10 +308,13 @@ class MumbleBot:
 | 
				
			|||||||
            else:
 | 
					            else:
 | 
				
			||||||
                time.sleep(0.1)
 | 
					                time.sleep(0.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (self.thread is None or not raw_music) and len(var.playlist) != 0:
 | 
					            if self.thread is None or not raw_music:
 | 
				
			||||||
 | 
					                if len(var.playlist) != 0:
 | 
				
			||||||
                    var.current_music = [var.playlist[0][0], var.playlist[0][1], None, None]
 | 
					                    var.current_music = [var.playlist[0][0], var.playlist[0][1], None, None]
 | 
				
			||||||
                    var.playlist.pop(0)
 | 
					                    var.playlist.pop(0)
 | 
				
			||||||
                    self.launch_next()
 | 
					                    self.launch_next()
 | 
				
			||||||
 | 
					                elif len(var.playlist) == 0 and var.current_music:
 | 
				
			||||||
 | 
					                    var.current_music = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while self.mumble.sound_output.get_buffer_size() > 0:
 | 
					        while self.mumble.sound_output.get_buffer_size() > 0:
 | 
				
			||||||
            time.sleep(0.01)
 | 
					            time.sleep(0.01)
 | 
				
			||||||
@@ -326,10 +342,11 @@ def start_web_interface(addr, port):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    parser = argparse.ArgumentParser(description='Bot for playing radio stream on Mumble')
 | 
					    parser = argparse.ArgumentParser(description='Bot for playing music on Mumble')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # General arguments
 | 
					    # General arguments
 | 
				
			||||||
    parser.add_argument("--config", dest='config', type=str, default='configuration.ini', help='Load configuration from this file. Default: configuration.ini')
 | 
					    parser.add_argument("--config", dest='config', type=str, default='configuration.ini', help='Load configuration from this file. Default: configuration.ini')
 | 
				
			||||||
 | 
					    parser.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="Only Error logs")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Mumble arguments
 | 
					    # Mumble arguments
 | 
				
			||||||
    parser.add_argument("-s", "--server", dest="host", type=str, required=True, help="The server's hostame of a mumble server")
 | 
					    parser.add_argument("-s", "--server", dest="host", type=str, required=True, help="The server's hostame of a mumble server")
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								pymumble
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								pymumble
									
									
									
									
									
								
							 Submodule pymumble updated: d9f70dd61d...d2ad1fde0c
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
opuslib==1.1.0
 | 
					opuslib==2.0.0
 | 
				
			||||||
protobuf==3.1.0
 | 
					protobuf==3.4.0
 | 
				
			||||||
flask
 | 
					flask
 | 
				
			||||||
youtube-dl
 | 
					youtube-dl
 | 
				
			||||||
python-magic
 | 
					python-magic
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,7 +66,20 @@
 | 
				
			|||||||
    </form>
 | 
					    </form>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<br />
 | 
					<div id="url">
 | 
				
			||||||
 | 
					    Add Youtube/Soundcloud URL :
 | 
				
			||||||
 | 
					    <form method="post">
 | 
				
			||||||
 | 
					        <input type=text name="add_url">
 | 
				
			||||||
 | 
					        <input type="submit" value="Add URL">
 | 
				
			||||||
 | 
					    </form>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					<div id="radio">
 | 
				
			||||||
 | 
					    Add Radio URL :
 | 
				
			||||||
 | 
					    <form method="post">
 | 
				
			||||||
 | 
					        <input type=text name="add_radio">
 | 
				
			||||||
 | 
					        <input type="submit" value="Add Radio">
 | 
				
			||||||
 | 
					    </form>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div id="playlist">
 | 
					<div id="playlist">
 | 
				
			||||||
    Currently Playing :
 | 
					    Currently Playing :
 | 
				
			||||||
@@ -84,7 +97,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    <ul>
 | 
					    <ul>
 | 
				
			||||||
        {% for m in playlist %}
 | 
					        {% for m in playlist %}
 | 
				
			||||||
        <li>{{ m }}
 | 
					        <li>{{ m[0] }} - {{ m[1] }}
 | 
				
			||||||
            <form method="post"><input type="text" value="{{ m }}" name="delete_music" hidden><input type="submit" value="X"></form>
 | 
					            <form method="post"><input type="text" value="{{ m }}" name="delete_music" hidden><input type="submit" value="X"></form>
 | 
				
			||||||
        </li>
 | 
					        </li>
 | 
				
			||||||
        {% endfor %}
 | 
					        {% endfor %}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user