feat(init): Initial config
This commit is contained in:
		
							parent
							
								
									4b3280dc42
								
							
						
					
					
						commit
						caca9fea92
					
				@ -1,3 +1,6 @@
 | 
				
			|||||||
# somafm-scripts
 | 
					# somafm-scripts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A collection of scripts about SomaFM
 | 
					A collection of scripts about SomaFM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `random-somafm.sh` : Picks up a random SomaFM station
 | 
				
			||||||
 | 
					  Unfortunately, it requires xmllint, which is not installed on Tilde Town.
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										25
									
								
								random-somafm.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								random-somafm.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					# This script aims at getting a random SomaFM channel
 | 
				
			||||||
 | 
					# I may make it a "SOMAFM channel library" if I feel like it.
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# 2023 - ydreniv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					XML_URL="https://somafm.com/channels.xml"
 | 
				
			||||||
 | 
					XML_DOC="/tmp/somafm_channels.xml"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					curl "$XML_URL" -o $XML_DOC -s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# get the number of channels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					channel_count=$(xmllint --xpath 'count(/channels/channel)' "$XML_DOC")
 | 
				
			||||||
 | 
					echo "There are $channel_count channels."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# print all channels ID
 | 
				
			||||||
 | 
					# xmllint --xpath '/channels/channel/@id' "$XML_DOC"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# get random channel
 | 
				
			||||||
 | 
					rdnum=$(( ( RANDOM % $channel_count ) + 1 ))
 | 
				
			||||||
 | 
					chan_name=$(xmllint --xpath "/channels/channel[$rdnum]/title/text()" "$XML_DOC" --nocdata)
 | 
				
			||||||
 | 
					chan_pls=$(xmllint --xpath "/channels/channel[$rdnum]/highestpls/text()" "$XML_DOC")
 | 
				
			||||||
 | 
					chan_id=$(xmllint --xpath "string(/channels/channel[$rdnum]/@id)" "$XML_DOC")
 | 
				
			||||||
 | 
					chan_url="https://somafm.com/$chan_id"
 | 
				
			||||||
 | 
					echo "$chan_name - $chan_url : $chan_pls"
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user