N
N
Narical2011-01-10 01:49:04
linux
Narical, 2011-01-10 01:49:04

Linux and downloading music from VKontakte - bring the script to mind?

First, the backstory, which is quite drawn to a miniature topic.
So, your music collection is in VKontakte, and you wanted to steal it to hards, as I wanted. The bulk of the solutions offered on the Internet are all sorts of left-handed utilities under Win, to which you need to feed your account data (yes, give them to someone on a silver platter). These utilities add a "download" button to every song, offering (again) silly manual labor.
The following script was found on the Internet:

<font color="black"><ol>
<li>#!/bin/bash</li>
<li>gets=`curl -s --data <font color="#A31515">&quot;[email protected]&pass=yourpassword&quot;</font> http:<font color="#008000">//login.vk.com/?act=login | egrep -o \([a-z]\|[0-9]\){20\,}`</font></li>
<li>curl -v --cookie-jar /tmp/vkcookie --data <font color="#A31515">&quot;s=$gets&op=slogin&redirect=1&expire=0&to=0&quot;</font> http:<font color="#008000">//vkontakte.ru/login.php</font></li>
<li>curl -v --cookie /tmp/vkcookie <a href="http://vkontakte.ru/audio.php">vkontakte.ru/audio.php</a> | grep -o <font color="#A31515">'http.*mp3'</font> | wget -i -</li>
</ol></font><font color="gray">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><font color="gray">Source Code Highlighter</font></a>.</font>

This script pulls music from the user's "audio recording" page in just 3 lines. Instead of a line
<a href="http://vkontakte.ru/audio.php">vkontakte.ru/audio.php</a>
you can enter any link in the contact, for example, on the "audio recording" page of a group (I checked, it works).
Well, now the question, or rather a request to knowledgeable people - help bring the script to mind.
The fact is that it saves music to files with the names fd8787fdsf98.mp3 (but with tags!), and if at some point the connection was interrupted, or wget hung, or the terminal was accidentally closed, you will either have to deal with parsing the “looted” from in order to remove from the VKontakte records those songs that have already been downloaded, or download everything again. And it downloads slowly - I'm not an expert in wget's parameters, but even the Opera download manager gives more speed.
That is, you need to add a check to see if the file has already been downloaded.
Among other things, I’m not at all sure that the script climbs somewhere beyond the first page with a list of music - I didn’t undertake to check this fact, it even downloads the first page for a very long time.
It would be very nice to screw some interface using gxmessage or zenity - to drive in account data in the window, and not enter it in the body of the script, because the latter is insecure (I almost published a script with my login and password, if anything). Well, the choice of source is the page of the user's audio recordings, or the recordings of some group (it is enough to pass only the GID to the script so that it generates a link), or enter the entire address manually (for example, a link to someone's wall from where you want to pull out the posted music) . During the grabbing process, you can issue the completion of downloading the next track via notify-send, or use the progress bar option for zenity.
Maybe this task will be of interest to someone from the Linux guru?
PS the original script is not my work,it is difficult to indicate authorship ;

Answer the question

In order to leave comments, you need to log in

13 answer(s)
U
ufolog, 2011-01-10
@Narical

what about mielophone.com/ ?
1) available under Linux for Adobe AIR
2) in the settings you can select as source - api.vk.com, which does not require any logins and passwords
3) allows you to download the entire music library in 2 clicks, while maintaining the original names of the songs
4) very simple in use and has many additional features

R
Riateche, 2011-01-10
@Riateche

In order not to download files a second time, it is enough to pass the -c switch to wget.
I can help with data entry. As far as I understand, you need to ask the user:
- email
- password
- type of page he is interested in
- id
Correct?
Give examples of links corresponding to different user choices. And then I don’t sit in contact, I’m too lazy to look for myself, where are the links.

R
recky, 2011-01-10
@recky

A graphical interface on the condition of the problem can not be used?
If possible, there is another option Exaile + script for VKontakte . This, of course, is not the way of the guru, but with a small number of tracks it works well. I have not tried it with a large one, but, in theory, it should also be fine. The titles of the tracks are written in the normal form. Plus, you can choose what to download and what not to download.

R
Robotex, 2011-01-10
@Robotex

I would do this: run DragonFly in the opera and press the play button for all the songs, then drag the received links into the opera rocking chair. Yes, manual labor, but simple and clear.

A
Alexey, 2011-01-10
@alexxxst

> and if at some point the connection was interrupted, or wget hung, or the
wget -c terminal was accidentally closed

W
whynot, 2011-01-10
@whynot

I have a working solution in php + mysql, which has not been brought to the state of a service site. I can share if relevant. There and authorization and the correct naming of files.

N
Narical, 2011-01-10
@Narical

Guys, it's all the same crutches. Point by point
- the solution with exaile is at first glance pretty, but it's definitely not a unix-way, I don't have the same exaile (and I really don't want to put it on my minimalistic archie) and a few more complaints, starting with the fact that the task is tearing out music from a specific page specified. That is, you went into the group, clicked on “audio recordings” - there are 20 of them. Selected a link or just a group id from it, launched the script, a gtk window popped up (gxmessage or zenity provides such functionality for *sh-scripts). You enter your login and password there and paste the link into the third field, and it pulls out all the tracks.
- php + mysql is also not unix-way, it's more like hammering nails with a microscope in my case. That is, at the moment, instead, a 3-line bash script almost manages. Is it reasonable to compare it with installing and configuring the Apache+php+muscle bundle?
“The same goes for Dragonfly. If I have a large selection in my records, then I will have to sit like a crab in the galleys.

N
Narical, 2011-01-10
@Narical

Even some I am unassembled at 8 am)
- about exaile - the point is not to do the work already done on collecting a large track list. That is, searching for all the songs again is not the same.
- about the http service, if you do not install it on your machine, then the option of using an intermediary when logging in to VKontakte is also very bad.

N
Narical, 2011-01-10
@Narical

Fine!
Look here. Audio recordings of some group:
vkontakte.ru/audio.php?gid=9538168
Audio recordings of the current user:
vkontakte.ru/audio.php
If you switch to the next/previous page of records: the
second page of records of the current user (in this case, me)
vkontakte.ru /audio.php#album_id=0&gid=0&id=1172148&offset=100
first page
vkontakte.ru/audio.php#album_id=0&gid=0&id=1172148&offset=0
sixth page of another user's entries
vkontakte.ru/audio.php?id=4564440# album_id=0&gid=0&id=4564440&offset=500
If you set the offset a lot, then the last of the existing pages is loaded anyway, that is, if there are only 2 compositions on the sixth page, and you set the offset to 99999, then the sixth page is loaded, but 99999 remains in the address bar. In theory, this fact can be used , that is, add 100 to the offset and compare with the previous page downloaded by wget, if the size is the same, then stop everything and report via notify-send that everything has been downloaded. Although it would be more correct to count the hash, rather than compare by size.
I think there is no difference between your own records and those of others in terms of address generation.
Only the user ID is different.

S
stampoon, 2011-01-10
@stampoon

Sorry, I can’t ask a question, so I’ll write in the comments, maybe they came across. I would like to implement a script for downloading audio files to a contact (not convenient one at a time), I did authorization, but I didn’t figure out how to send multipart via curl in a human way, tell me, if it’s not difficult. Preferably with an example.
PS if anyone needs authorization:
#!/bin/bash
RND=$RANDOM$RANDOM$RANDOM$RANDOM
touch /tmp/cookievk$RND
curl -c /tmp/cookievm$RND -d "email=$1&pass=$2" 'http ://vkontakte.ru/login.php' 2> /dev/null
SID=$(cat /tmp/cookievk$RND | grep sid | tail -c-57)
rm -rf /tmp/cookievk$RND
if [ " $SID" != "" ]; then
echo "$1 - $2 - $SID"
fi
PPS vk checks only the header for mp3x, so you can store files in them at the end, if anyone is interested - I wrote a small conversion script (curve code, but working)
stampoon.dyndns.org/Vkfile/

N
Narical, 2011-01-10
@Narical

I myself don’t understand the intricacies, but the script I provided also has authorization, and it’s somehow different, but it works. I can't really answer.

N
Narical, 2011-01-10
@Narical

Sounds like this is the solution.
So far, it has not been possible to try - AIR has not been installed on the fly, it says there are no access rights. Well, apparently, you just need to install it from the root, but I launched it from the Opera.
But this is definitely not the unix-way :)
In general, if anyone else wants to modify the script, please write it down! I'll poke the "solution" for now, but the unix-way is more interesting!

O
osj, 2011-01-10
@osj

Of course, I'm sorry, but maybe the author will try the script from ru.savefrom.net

How to download music from a contact
1) When you hover your mouse over the track name, the links "Download" and "Options" will appear. By clicking on the "Parameters" link, you can determine the quality (bitrate) and size of the mp3 file. The bitrate is determined by the file size, so its value is an approximation.
2) In order to immediately download all the music from the page, call the SaveFrom.net assistant menu and select the item: "Download all mp3 files".
3) You can also save the playlist to your computer for later opening in a media player. To do this, select the item: "Download mp3 playlist" in the assistant menu.

works in Mozilla Firefox, Google Chrome, Opera which also work under linux.
The resulting list of links is already fed to the download manager ...
well, if the author does not use a purely console.
ah, the script saves under names like fd8787fdsf98.mp3, sorry. obviously won't fit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question