I made a script to track what music player (vlc) is playing and not play it next time

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Hello everyone! I have made a lot of weird but useful scripts over the years I am using linux and I don’t really know where to share them so I’ll start posting them here. I am waiting feedback if this is a good place to share them or not and how can I improve them. I think github is not a good option really as they are quite simple but I might use it. Anyway this bash script checks what vlc is playing every 10 seconds (can be changed at line 9) checks if that song exists in the playlist file and removes it from the playlist file (if it does exist). Next time I open the playlist.m3u with vlc it won’t have the songs it played the previous time. I needed to make this because I have a huge library playing in shuffle all the time. But I always end up listening to the same songs over and over again cause the playlist will reload each time I open it. So I have a backup playlist which has all the songs, a playlist with the played songs removed and I always open that one with vlc. Here is the bash script: #!/usr/bin/bash #usage: progname /path/to/playlist-file.m3u filename=”$1″ vlc $filename &>/dev/null & sleep 3 pid=$(pidof -s vlc) while [[ $pid ]]; do sleep 10 pid=$(pidof -s vlc) if [[ ! $pid ]]; then break fi songname=$(lsof -p `pidof -s vlc` | grep -o “/.*.mp3” | sed -E “s/.+Music/(.+).mp3/1/”) deletioncheck=$(grep -o “$songname” $filename) if [[ $songname = $deletioncheck ]]; then linenumber=$(grep -n “$songname” $filename | sed -E “s/^([0-9]+):.+$/1/g”) nextlinenumber=$((linenumber+1)) thed=”d” sed -i “$linenumber$thed;$nextlinenumber$thed” $filename fi done Of course it can be used with other music players (line 5,7,10,14). In line 14 you can change the path to where your songs are. Unfortunately it assumes they are all in the same directory. But that is no problem as I made a script where it autosorts and moves files in the correct directories as well as moving them out of directories! But I will post that another time if you want of course. 🙂 What do you think? submitted by /u/orestisfra [link] [comments]

X ITM Cloud News

Sofia .

Leave a Reply

Next Post

How to Use Spring Retry Template

Tue Jun 30 , 2020
Spread the love          In the cloud computing world, one of the pivotal parts is networking, the fact is that we cannot avoid network glitches and there will be temporary disconnection for a couple of seconds which makes the operations break while doing network-related configuration from the cloud-native applications. I am going […]
X- ITM

Cloud Computing – Consultancy – Development – Hosting – APIs – Legacy Systems

X-ITM Technology helps our customers across the entire enterprise technology stack with differentiated industry solutions. We modernize IT, optimize data architectures, and make everything secure, scalable and orchestrated across public, private and hybrid clouds.

This image has an empty alt attribute; its file name is x-itmdc.jpg

The enterprise technology stack includes ITO; Cloud and Security Services; Applications and Industry IP; Data, Analytics and Engineering Services; and Advisory.

Watch an animation of  X-ITM‘s Enterprise Technology Stack

We combine years of experience running mission-critical systems with the latest digital innovations to deliver better business outcomes and new levels of performance, competitiveness and experiences for our customers and their stakeholders.

X-ITM invests in three key drivers of growth: People, Customers and Operational Execution.

The company’s global scale, talent and innovation platforms serve 6,000 private and public-sector clients in 70 countries.

X-ITM’s extensive partner network helps drive collaboration and leverage technology independence. The company has established more than 200 industry-leading global Partner Network relationships, including 15 strategic partners: Amazon Web Services, AT&T, Dell Technologies, Google Cloud, HCL, HP, HPE, IBM, Micro Focus, Microsoft, Oracle, PwC, SAP, ServiceNow and VMware

.

Cloud Services Live Updates Contact Us




X ITM