Movies2HDD
A simple set of python scripts and libraries to work with movies. I use it with my DreamBox.
 All Classes Namespaces Files Functions Variables Pages
lbi.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 '''A line-based interface to Movies2HDD.'''
3 
4 print ("Movies2HDD's line-based interface Copyright (C) 2013 Niklas Sombert")
5 print ("This program comes with ABSOLUTELY NO WARRANTY.")
6 print ("This is free software, and you are welcome to redistribute it")
7 print ("under certain conditions.")
8 
9 print ("")
10 
11 print ("Loading libraries...")
12 import movies2hdd
13 Movies2HDD = movies2hdd.Movies2HDD()
14 from getpass import getpass
15 import sys
16 if sys.version_info.major == 2:
17  ask = raw_input
18 elif sys.version_info.major == 3:
19  ask = input
20 else:
21  print ("What version of Python are you using?!")
22  quit()
23 print ("")
24 
25 print ("Movies2HDD")
26 def connect():
27  print ("Connect to your DreamBox")
28  host = ask("Host: ")
29  user = ask("User: ")
30  print ("Your password will be sent unencryptedly!!!")
31  print ("Don't do this if you don't trust this network.")
32  print ("Otherwise, please tunnel this connection via SSH.")
33  pwd = getpass("Password: ")
34  print ("Connecting...")
35  Movies2HDD.connect(host, user, pwd)
36 #
37 def disconnect():
38  print ("Disconnecting...")
39  Movies2HDD.disconnect()
40 #
41 def search():
42  print ("Search for movies")
43  search = ask("Search for: ")
44  print ("")
45  result = Movies2HDD.getAviableMovies(search)
46  print ("The following movies were found:")
47  i = 0
48  for x in result:
49  i += 1
50  print (" [" + str(i) + "] " + x)
51  print ("")
52  print ("Which of them do you want to download?")
53  print ("Please type in the numbers and seperate them with a ',' (e.g. '1,5,7,42,1234').")
54  selection_input = ask("> ")
55  movies_to_get = []
56  for x in selection_input.split(","):
57  x = int(x)-1
58  movies_to_get.append(result[x])
59  print ("")
60  print ("The following movies are selected to be downloaded:")
61  for x in movies_to_get:
62  print (" * " + x)
63  movies = movies_to_get
64 #
65 def select():
66  pass
67  #filetype = ?
68 #
69 def save():
70  print ("Where do you want to save the movies?")
71  path = ask("> ")
72  #do something
73 #
74 def download():
75  pass
76  #filetype = "ts"
77 #
78 def rename():
79  pass
80 #
81 def convert():
82  if filetype == "ts":
83  for x in movies:
84  Movies2HDD.convertMovie(x)
85  elif filetype == "mpg":
86  print ("The files are already .mpg.")
87  else:
88  print ("What?!")
89  print ("... file type are you using?")
90  quit()
91 #
92 def quit():
93  print ("Exiting...")
94  sys.exit()
95 #
96 while True:
97  print ("")
98  print ("What do you want to do next?")
99  print (" [1] Connect to your DreamBox")
100  print (" [2] Disconnect from your DreamBox")
101  print (" [3] Search for movies (needs a connection)")
102  print (" [4] Select movies from your disk (not implemented yet!)")
103  print (" [5] Save movies to your disk (needs a list of movies)")
104  print (" [6] Download movies (needs a connection and a list of movies)")
105  print (" [7] Rename movies (needs a list of movies)")
106  print (" [8] Convert movies (needs a list of movies)")
107  print (" [9] Quit (disconnect first!)")
108  print ("")
109  answer = int(ask("> "))
110  print ("")
111  if answer == 1:
112  connect()
113  if answer == 2:
114  disconnect()
115  if answer == 3:
116  search()
117  if answer == 4:
118  select()
119  if answer == 5:
120  save()
121  if answer == 6:
122  download()
123  if answer == 7:
124  rename()
125  if answer == 8:
126  convert()
127  if answer == 9:
128  quit()