convert audio files (need ffmpeg)
This commit is contained in:
		
							parent
							
								
									acae10d185
								
							
						
					
					
						commit
						cdc6923a25
					
				
							
								
								
									
										13
									
								
								publish.py
								
								
								
								
							
							
						
						
									
										13
									
								
								publish.py
								
								
								
								
							| 
						 | 
				
			
			@ -3,6 +3,7 @@ import re
 | 
			
		|||
import markdown
 | 
			
		||||
import yaml
 | 
			
		||||
import shutil
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
htmltemplate = """<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
| 
						 | 
				
			
			@ -76,9 +77,19 @@ for folderinfo in index['folders']:
 | 
			
		|||
            htmlhome += "<li><a href=\"{}\">{}</a></li>".format(filename.replace('.md', '.html'), filetitle)
 | 
			
		||||
            gmihome += "\n=> {} {}".format(filename.replace('.md', '.gmi').replace(' ', '%20'), filetitle)
 | 
			
		||||
 | 
			
		||||
        else:
 | 
			
		||||
        elif fileextension == ".wav" or fileextension == ".3gp":
 | 
			
		||||
 | 
			
		||||
            # sounds
 | 
			
		||||
            # todo: add a property for dest file (to remove accents)
 | 
			
		||||
 | 
			
		||||
            # todo use builtin library
 | 
			
		||||
            subprocess.run(["ffmpeg",
 | 
			
		||||
                "-i",
 | 
			
		||||
                os.path.join(folderinfo['folder'], filename),
 | 
			
		||||
                os.path.join('out/html', fileroot + ".mp3")])
 | 
			
		||||
            htmlhome += "<li>{}</li><audio controls><source src=\"{}\"></audio>".format(filetitle, filename)
 | 
			
		||||
 | 
			
		||||
        elif fileextension == ".mp3":
 | 
			
		||||
            shutil.copy(os.path.join(folderinfo['folder'], filename), 'out/html')
 | 
			
		||||
            htmlhome += "<li>{}</li><audio controls><source src=\"{}\"></audio>".format(filetitle, filename)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue