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
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
movies2hdd.Movies2HDD Class Reference

Public Member Functions

def __init__
 
def connect
 
def disconnect
 
def getAviableMovies
 
def getTitleOfEpisode
 
def getSeries
 
def getPositionOfEpisode
 
def downloadMovie
 
def convertMovie
 

Public Attributes

 conn
 

Static Public Attributes

tuple dom = parseString(apianswer)
 
tuple episodes = dom.getElementsByTagName("Episode")
 
int season = 0
 
tuple episode = x.getElementsByTagName("Combined_episodenumber")
 
tuple season = x.getElementsByTagName("Combined_season")
 
list episode = episode[0:episode.find(".")]
 

Detailed Description

A simple set of python scripts and libraries to work with movies. I use it with my DreamBox.

Definition at line 29 of file __init__.py.

Constructor & Destructor Documentation

def movies2hdd.Movies2HDD.__init__ (   self)
The __init__. What else?

Definition at line 32 of file __init__.py.

32 
33  def __init__(self):
34  """The __init__. What else?"""
35  pass

Member Function Documentation

def movies2hdd.Movies2HDD.connect (   self,
  host,
  user,
  pwd 
)
Connect to a DreamBox using the given host and credentials.

Definition at line 36 of file __init__.py.

36 
37  def connect(self, host, user, pwd):
38  """Connect to a DreamBox using the given host and credentials."""
39  self.conn = ftplib.FTP()
40  print((self.conn.connect(host)))
41  print((self.conn.login(user, pwd)))
42  print((self.conn.cwd("/media/hdd/movie")))
43  #return conn
def movies2hdd.Movies2HDD.convertMovie (   self,
  movie 
)
Convert a movie. It will remove additional audio tracks!

Definition at line 134 of file __init__.py.

135  def convertMovie(self, movie):
136  """Convert a movie. It will remove additional audio tracks!"""
137  if subprocess.Popen(["projectx", "/tmp/"+movie+".ts"]).wait() != 0: #threading?
138  raise BaseException
139  files = os.listdir("/tmp")
140  contents = list()
141  for x in files:
142  print("There is "+x+".")
143  if x.startswith(movie):
144  print("It belongs to us! "+x)
145  #if x.find("[") == -1 and x.find("_log") == -1 and x.find(".ts") == -1:
146  #contents.append(x[x.index("."):x.count("")-1])
147  if x.endswith(".ac3"):
148  contents.append(".ac3")
149  print(x+" is in.")
150  elif x.endswith(".mp2") and x.find("[") == -1:
151  contents.append(".mp2")
152  print(x+" is in.")
153  elif x.endswith(".m2v"):
154  contents.append(".m2v")
155  print(x+" is in.")
156  elif x.endswith(".ts"):
157  contents.append(".ts")
158  print(x+" will not be deleted for now.")
159  else:
160  os.remove("/tmp/"+x)
161  print(x+" removed.")
162  print("We have got the following files:")
163  print(contents)
164  if contents.count(".m2v") != 0:
165  if contents.count(".ac3") != 0:
166  if subprocess.Popen(["mplex","-f","3","-o","/tmp/"+movie+".mpg","/tmp/"+movie+".ac3","/tmp/"+movie+".m2v"]).wait() != 0: #threading?
167  raise BaseException
168  elif contents.count(".mp2") != 0:
169  if subprocess.Popen(["mplex","-f","3","-o","/tmp/"+movie+".mpg","/tmp/"+movie+".mp2","/tmp/"+movie+".m2v"]).wait() != 0: #threading?
170  raise BaseException
171  else:
172  print("No audio in here.")
173  #return False
174  raise BaseException
175  else:
176  print("No video in here.")
177  #return False
178  raise BaseException
179  for x in contents:
180  print("deleting "+movie+x+"...")
181  os.remove("/tmp/"+movie+x)
def movies2hdd.Movies2HDD.disconnect (   self)
Close the connection.

Definition at line 44 of file __init__.py.

44 
45  def disconnect(self):
46  """Close the connection."""
47  print((self.conn.quit()))
48  return
def movies2hdd.Movies2HDD.downloadMovie (   self,
  movie 
)
Download a video from your DreamBox.

Definition at line 122 of file __init__.py.

123  def downloadMovie(self, movie):
124  """Download a video from your DreamBox."""
125  file = open("/tmp/"+movie+".ts", "wb")
126  result = self.conn.retrbinary("RETR "+movie+".ts", file.write, 8*1024) #perhaps implement threading ;-)
127  print(result)
128  file.close()
129  if result.startswith("2") == False:
130  raise BaseException
131  else:
132  print("TODO")
133  #print(self.conn.delete(movie)) #TODO
def movies2hdd.Movies2HDD.getAviableMovies (   self,
  search 
)
List movies aviable on your DreamBox.

Definition at line 49 of file __init__.py.

49 
50  def getAviableMovies(self,search):
51  """List movies aviable on your DreamBox."""
52  allfiles = self.conn.nlst()
53  newlist = list()
54  for each in allfiles:
55  if each.find(search) != -1:
56  newlist.append(each)
57  movies = list()
58  for each in newlist:
59  if each.endswith(".ts"):
60  movies.append(each.replace(".ts", ""))
61  return movies
def movies2hdd.Movies2HDD.getPositionOfEpisode (   self,
  lang,
  seriesid,
  episode 
)
Get the season and episode number of an episode.

Definition at line 100 of file __init__.py.

101  def getPositionOfEpisode(self, lang, seriesid, episode):
102  """Get the season and episode number of an episode."""
103  try:
104  apianswer = urllib.urlopen("http://thetvdb.com/api/FE84E205C6E3D916/series/"+str(seriesid)+"/all/"+lang+".xml").read()
105  except AttributeError:
apianswer = urllib.request.urlopen("http://thetvdb.com/api/FE84E205C6E3D916/series/"+str(seriesid)+"/all/"+lang+".xml").read()
def movies2hdd.Movies2HDD.getSeries (   self,
  series 
)
Get the id of the series.

Definition at line 71 of file __init__.py.

71 
72  def getSeries(self, series):
73  """Get the id of the series."""
74  try:
75  api = urllib.urlopen("http://thetvdb.com/api/GetSeries.php?seriesname="+series)
76  except AttributeError:
77  api = urllib.request.urlopen("http://thetvdb.com/api/GetSeries.php?seriesname="+series)
78  apianswer = api.read()
79  api.close()
80 
81  series = []
82  try:
83  seriesdom = parseString(apianswer).getElementsByTagName("Data")[0].getElementsByTagName("Series")
84  for x in seriesdom:
85  seriesid = x.getElementsByTagName("seriesid")[0].firstChild.data
86  seriesname = x.getElementsByTagName("SeriesName")[0].firstChild.data
87  try:
88  overview = x.getElementsByTagName("Overview")[0].firstChild.data
89  except IndexError:
90  overview = ""
91  series.append({
92  'seriesid': seriesid,
93  'SeriesName': seriesname,
94  'Overview': overview
95  })
96  except IndexError:
97  pass
98 
99  return(series)
def movies2hdd.Movies2HDD.getTitleOfEpisode (   self,
  movie 
)
Get the title of an episode. It uses the .ts.meta file that are automatically stored with your recordings.

Definition at line 62 of file __init__.py.

62 
63  def getTitleOfEpisode(self, movie):
64  """Get the title of an episode. It uses the .ts.meta file that are automatically stored with your recordings."""
65  meta = list()
66  self.conn.retrlines("RETR "+movie+".ts.meta", meta.append)
67  if meta[1] == meta[2]:
68  return False #Titel wurde nicht bei der Aufnahme gespeichert
69  else:
70  return meta[2]

Member Data Documentation

movies2hdd.Movies2HDD.conn

Definition at line 38 of file __init__.py.

tuple movies2hdd.Movies2HDD.dom = parseString(apianswer)
static

Definition at line 108 of file __init__.py.

tuple movies2hdd.Movies2HDD.episode = x.getElementsByTagName("Combined_episodenumber")
static

Definition at line 113 of file __init__.py.

list movies2hdd.Movies2HDD.episode = episode[0:episode.find(".")]
static

Definition at line 116 of file __init__.py.

tuple movies2hdd.Movies2HDD.episodes = dom.getElementsByTagName("Episode")
static

Definition at line 109 of file __init__.py.

int movies2hdd.Movies2HDD.season = 0
static

Definition at line 110 of file __init__.py.

tuple movies2hdd.Movies2HDD.season = x.getElementsByTagName("Combined_season")
static

Definition at line 114 of file __init__.py.


The documentation for this class was generated from the following file: