music.py
1 |
|
2 |
music.py is a little script I made that allows to easily download my music |
3 |
from my main computer (Which has more storage space than my laptop) in a |
4 |
fashionable way. It uses SFTP through the Paramiko library |
5 |
(https://github.com/paramiko/paramiko). |
6 |
|
7 |
The functionality can be expressed as follows: |
8 |
- On the remote music directory, the music is divided in subfolders, |
9 |
according to (main) performing artist. In there, there will either be more |
10 |
subfolders (which would be albums) |
11 |
- In these folders, there are music files, which should be file types like |
12 |
FLAC and ogg, with a certain name. There may also be files with the same |
13 |
name, but with another filetype, like .ogv. |
14 |
- Video files serve as the videoclips for said music files. If there is no |
15 |
music file, it's assumed the music file is the same as the video file, |
16 |
less the video itself. |
17 |
- There may also be subtitle files, like .srt which will store the lyrics of |
18 |
said song. |
19 |
""" |
20 |
|
21 |
# Importing necessary libraries |
22 |
import paramiko |
23 |
|
24 |
# Defining constant values for use throughout the program |
25 |
NAME = "maarten" # Name to be used on the remote server. |
26 |
LOCAL_MUSIC_DIRECTORY = "~/Music/" |
27 |
REMOTE_MUSIC_DIRECTORY = "~/Muziek/" # I blame being Belgian. |
28 |
|
29 |
key = paramiko.RSAKey(data=base64.decodestring('AAA...')) |
30 |
client = paramiko.SSHClient() |
31 |
client.get_host_keys().add('ssh.example.com', 'ssh-rsa', key) |
32 |
|
33 |
def connect_to_server(serverAddress, userName, passphrase): |
34 |
pass |
35 |
|
36 |
serverAddress = "maartenv.be" |
37 |
|
38 |
client.connect('ssh.example.com', username='strongbad', password='thecheat') |
39 |
stdin, stdout, stderr = client.exec_command('ls') |
40 |
for line in stdout: |
41 |
print '... ' + line.strip('\n') |
42 |
client.close() |
43 |