Can I put comments in mpd playlist? - comments

The title says it all...
Running Ubuntu 12.04 and the mpd daemon.
I am writing some scripts to manipulate the playlists (for my wife and me,) and it would be handy to have comments in the playlist rather then create a separate log file.
So, canI, canI, canI???
Straight from my 5 year old.

You cannot. Here is the full list of all MPD commands related to stored playlists:
listplaylist {NAME}
listplaylistinfo {NAME}
listplaylists
load {NAME} [START:END]
playlistadd {NAME} {URI}
playlistclear {NAME}
playlistdelete {NAME} {SONGPOS}
playlistmove {NAME} {FROM} {TO}
rename {NAME} {NEW_NAME}
rm {NAME}
save {NAME}
You can use "stickers" to associate arbitrary information per song, but sadly (and inexplicably) you cannot (yet?) associate stickers with playlists.
You can also read all comments from a song file using readcomments.

Related

How can I get metadata of file and assign it to variables?

I have a pdf file.
I want to get that file's (filename, size, pages, author, subject) metadata tags and assign it to different variables into automator app. Can someone help me with this?
The bash command mdls '/path/to/file.pdf' should return all of the metadata for a pdf file. if you run this in a run shell script action, it will produce a list of all metadata that can be processed by a subsequent action.
Alternately, you can ask for specific metadata keys like so:
mdls -name kMDItemFSName -name kMDItemNumberOfPages '/path/to/file.pdf'
Assigning these to different variables is a bit tedious, but not too difficult.

Store an API_KEY in an env var and use in a playlist URL

I use a streaming service (di.fm) that has many channels. Each channel has a playlist I stream from the CLI (using mpv). Each URL in each playlist stores the API KEY.
I want to store the API KEY outside of the individual playlists, so for example, if I change the API KEY, I don't have to change every playlist.
I'm on a Mac.
1) What is the best (safest) place to declare export DI_KEY=""? In .bashrc was my first thought, except I back it up to github. Any other better place to declare the env var that will be created each time I enter bash?
2) In the playlist file, how do I use the $DI_KEY in the URL?
[playlist]
NumberOfEntries=1
File1=http://prem4.di.fm:80/00sclubhits?$DI_KEY
Title1=DI.FM - 00s Club Hits
Length1=0
Version=2
Just referencing it directly doesn't work.
I'm sure this may be answered elsewhere, but in all my searching I couldn't find any helpful answers, particularly to questions 2.
Regarding setting env variables outside of .bashrc, you could create a separate file to define sensitive variables and source this from within your .bashrc.
For example, create a file ~.my-private-variables, add the filename to your .gitignore and add the line export DI_KEY="12345" to this file. Then add the following block in .bashrc:
if [ -f ~/.my-private-variables ]; then
. ~/.my-private-variables
fi
Regarding the playlist file, bash is not running the file, so the environment variable is not expanded.
You could dynamically generate the playlist when bash starts, something like this:
#!/bin/bash
filename=playlist-1.pls
baseurl=http://prem4.di.fm:80
cat << EOF > $filename
[playlist]
NumberOfEntries=1
File1=${baseurl}/00sclubhits?${DI_KEY}
Title1=DI.FM - 00s Club Hits
Length1=0
Version=2
EOF
This will expand the variable and write it to the file, in this case playlist-1.pls in the current working directory. You might add an absolute path to the filename variable that references your playlists directory.
To run this, you could create a script called playlist-generator and source this in .bashrc as described above. You could add as many playlists as you like here.

download list of images from urls

I need to find (preferably) or build an app for a lot of images.
Each image has a distinct URL. There are many thousands, so doing it manually is a huge effort.
The list is currently in an csv file. (It is essentially a list of products, each with identifying info (name, brand, barcode, etc) and a link to a product image.
I'd like to loop through the list, and download each image file. Ideally I'd like to rename each one - something like barcode.jpg.
I've looked at a number of image scrapers, but haven't found one that works quite this way.
Very appreciative of any leads to the right tool, or ideas...
Are you on Windows or Mac/Linux? In Windows you can use a powershell script for this, on mac/linux a shell script with about 1-5 lines of code.
Here's one way to do this:
# show what's inside the file
cat urlsofproducts.csv
http://bit.ly/noexist/obj101.jpg, screwdriver, blackndecker
http://bit.ly/noexist/obj102.jpg, screwdriver, acme
# this one-liner will GENERATE one download-command per item, but will not execute them
perl -MFile::Basename -F", " -anlE "say qq(wget -q \$F[0] -O '\$F[1]--\$F[2]--). basename(\$F[0]) .q(')" urlsofproducts.csv
# Output :
wget http://bit.ly/noexist/obj101.jpg -O ' screwdriver-- blackndecker--obj101.jpg'
wget http://bit.ly/noexist/obj101.jpg -O ' screwdriver-- acme--obj101.jpg'
Now back-substitute the wget commands into the shell.
If possible please use google sheets to run a function for this kind of work, I was also puzzled on this one and now found a way to by which the images are not only downloaded but those are renamed on the real time.
Kindly reply if you want the code.

How to convert .csv to .xls

I have a simple .csv file.
Is it possible to convert it to .xls using the command line tool ssconvert?
I would also need to specify the name of the sheet.
ln -s input.csv MySheetName
ssconvert MySheetName output.xls
The OP asked how to convert csv to xls while controlling the sheet name in the output.
The generated .xls file will use the name of the input CSV file as the sheet name, so you can symlink the .csv to anything you want (or rename the input file) to produce the desired result.
The previous answer implies that --list-exporters leads to a solution, but it merely lists exporter names with no information about their options, and no options are documented in the man page for xls-exporters. Experimentally, none of the exporters which can create .xls accept options (they fail with "The file saver does not take options" if you use -O).
Yes, it is possible.
You must specify names with extensions as input and output files.
For example:
ssconvert in.csv out.xls
Using --list-importers and --list-exporters options can take a look to available formats.

Importing EXIF from filename

Ok, so there are a plethora of examples and apps using ExifTool to convert EXIF data to .jpg names. But what if you want to go the other way around? I have a number of files that use ODBC date, but contain no meta EXIF date. How can I - with what app or EXIFTool commandline - update the EXIF_DATE from a filename?
2012-02-24_1330073217.jpg
I found a Windows app
EXIFDate by filenamepattern that does this, but I'm a mac user. :/
This command will do what you want:
exiftool "-alldates<filename" DIR
where DIR is one or more directory and/or file names.

Resources