📜 ⬆️ ⬇️

A simple bash solution for sharing music and photos on Dropbox

Good luck to everyone!

It's no secret that Dropbox can be used to store business cards (though with some restrictions, they are lower). We all know that it is possible to make an almost ftp-server from dropbox with convenient viewing of the contents.

These methods are known to all, but they have a negative side. Firstly, html-content for users with Russian IP is not available. Secondly, these options for using the Public folder are not suitable for conveniently sharing a large number of pictures or music ( do not read further to pirates ). Fix it! Find a tool to create sites in the drop and insert music into them with listening online and pictures with thumbnails!
')
Immediately talk about the limitations. Dropbox does not allow to look html, it is so, but, as adminimus tells us here , we need to switch to XHTML. Yes, it is a bit unpleasant, but you quickly get used to it, but for simple layout it is almost not noticeable at all. So, we need a script that will receive a folder with files at the entrance, and at the output it will produce an .xhtml file with all the necessary content.

If you want to immediately get the code on bash, then I ask for github , and if you are interested in technical details, then - under the cat.

So, I chose to implement my bash idea. The script was created in Mac OS X, but should start in other systems, if you put all the dependencies: afinfo, mp3info, iconv, perl, sips . If you personally do not like any of these tools, feel free, so to speak, replace it with your favorite. The main problem, in my opinion, is the inability to process id3v2 file headers - mp3info does not understand them, but I was too lazy to look for a replacement for it.

At first I will tell about the general system structure There is a gen.sh script in which all the work takes place, there are files *_[header|footer].txt , in which, as you already guessed, there are templates for headers and page footers. Yes, you can do it better, but the easiest way. By the way, I am not a bit designer, so the current version looks a bit strange, so I recommend to customize the pages to your liking before using. The script accepts one required parameter and one optional: content type and search depth. Now the txt , mp3 and img types are supported, because I didn’t think to be with pyndexer, my script solves only particular problems. The type determines the directory in which the content will lie and in which you need to put .xhtml, now it's txt , mp3 and images , respectively. For each type, the list of file extensions to be indexed is also specified. Sorry for the hardcode, it just happened =). For each file, a direct link and its size are put into the code.

Next, for mp3-shek, we need an online player that can be inserted into your website. I chose the flash player from http://flv-mp3.com/ru/mp3/ , we download it and put it in the Public / mp3 / player.swf folder, and we will generate the embed code on our page in the script itself. . In addition to the player, we will also display the duration of the song on the page. Well, for convenience.

For the pictures we will do thumbnails, for this we will create a folder thumbs and we will put thumbnails there. We will also display the size of the image and its format. For convenience, yes.

Finally, we save our generated good to a file named Public / $ DIR / $ DIR.xhtml (why do index.xhtml if the dropbox is not an http server?), And after synchronizing the drop, we copy the public link to this file and send it to any friend - let them look at the fresh pictures and listen to Bach. Sorry, but I will not give a link to the demo - habraeffekt not merciful, but does not like dropbox and bans public links. But if anyone is interested, I can throw in a personal. The music directory looks like this:

In general, if someone read up to this place, I leave here again the link to the github, here it is: silvansky / Dropbox-XHTML-generator

Source: https://habr.com/ru/post/147095/


All Articles