summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2009-12-26 19:31:38 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2009-12-26 19:31:38 +0800
commitabdbeaf997628c51b4b27dd4027ca20ddc5ed749 (patch)
tree396c81bef9ccbe6f94af1e9b42770df5bdd9d11d
parentf78154887c46df98c840631f9979c8c210cc7b1b (diff)
totem: clean up the code, pack clsid and subclsid into a tuple
-rw-r--r--totem/plugin/ppstream.py877
-rw-r--r--totem/plugin/ppstream.ui6
2 files changed, 569 insertions, 314 deletions
diff --git a/totem/plugin/ppstream.py b/totem/plugin/ppstream.py
index a8ae496..6a37996 100644
--- a/totem/plugin/ppstream.py
+++ b/totem/plugin/ppstream.py
@@ -558,10 +558,8 @@ class PPStream (totem.Plugin):
### fetch next subclass
self.fetch_next_subclass (True)
- def threaded_parse_films (self, res, clsid, subclsid, page, count):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ def threaded_parse_films (self, res, class_path, page, count):
+ subcls = self.get_movie_class (class_path)
if not res:
subcls.parsing_films = False
@@ -569,20 +567,18 @@ class PPStream (totem.Plugin):
try:
result = self.ppslist.parseMovieList(subcls, res, page)
except Exception, e:
- print "Couldn't parse film list:", clsid, subclsid, e
+ print "Couldn't parse film list:", class_path, e
result = None
subcls.parsing_films = False
return result
- def on_films_fetched (self, res, clsid, subclsid, page, count, new = True):
+ def on_films_fetched (self, res, class_path, page, count, new = True):
if self.films_count != count:
return
### check if the server repeats the last page
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ subcls = self.get_movie_class (class_path)
if not hasattr(subcls, 'parsing_films'):
subcls.parsing_films = False
@@ -597,20 +593,18 @@ class PPStream (totem.Plugin):
subcls.parsing_films = True
process = ProcessThread (res, self.threaded_parse_films,
self.add_parsed_films,
- clsid, subclsid, page, count)
+ class_path, page, count)
process.start ()
self.update_progress_bar ()
return
- result = self.threaded_parse_films (res, clsid, subclsid, page, count)
- self.add_parsed_films (result, clsid, subclsid, page, count)
+ result = self.threaded_parse_films (res, class_path, page, count)
+ self.add_parsed_films (result, class_path, page, count)
- def add_parsed_films (self, result, clsid, subclsid, page, count):
+ def add_parsed_films (self, result, class_path, page, count):
if self.films_count != count or page != self.films_page:
return
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ subcls = self.get_movie_class (class_path)
if result:
subcls.addMovies(result, page)
@@ -620,216 +614,64 @@ class PPStream (totem.Plugin):
if result:
## for film in result:
## print film
- self.fill_films (result, clsid, subclsid)
+ self.fill_films (result, class_path)
self.set_page_max(subcls.getMaxPage())
def parse_class (self, res):
- self.ppslist.updateClasses(self.ppslist.parseClasses(res))
+ ### parse the class list
+ classes = self.ppslist.parseClasses(res)
+ for cls in classes:
+ cls.fetching_films = False
+ self.ppslist.updateClasses(classes)
### fill category list
self.clear_pages ('categories')
for cls in self.ppslist.getClasses():
self.fill_categories (cls.id)
- def download_subclass (self, index):
- subclsid = self.classes[index].id
- contentnum = self.classes[index].contentnum
- filename = os.path.join (pps_xmls_dir,
- 'subclass-%d-%d.xml' % (subclsid, contentnum))
- res = None
- if os.path.exists (filename):
- try:
- f = file (filename, 'r')
- res = f.read ()
- f.close ()
- except:
- pass
-
- if res:
- gobject.idle_add (self.on_subclasses_fetched, res)
- return
-
- url = 'http://playlist.pps.tv/subclassfortv.php?class='
- thread = DownloadThread (url + str (subclsid),
- self.on_subclass_downloaded,
- index)
- thread.start()
-
- def on_subclass_downloaded (self, res, index, *args):
- subclsid = self.classes[index].id
- contentnum = self.classes[index].contentnum
- filename = os.path.join (pps_xmls_dir,
- 'subclass-%d-%d.xml' % (subclsid, contentnum))
- try:
- f = file (filename, 'w')
- f.write (res)
- f.close ()
- except Exception, e:
- print "Couldn't save ", filename
- self.on_subclasses_fetched (res, *args)
-
- def fetch_subclass (self, index, show = False):
- self.subclass_index = index
- if self.classes[index].type == 1:
- if show:
- self.fill_categories (self.classes[index].id)
- self.fetch_next_subclass (show)
- return
- self.download_subclass (index)
-
- def fetch_next_subclass (self, show = False):
- if self.subclass_index < len(self.classes) - 1:
- self.fetch_subclass (self.subclass_index + 1, show)
-
- def parse_subclass (self, res):
- if not res:
- return
- xmldoc = minidom.parseString (res)
- clses = xmldoc.getElementsByTagName ('PPSSClasses')
- if not clses:
- return
- cls = clses[0].getElementsByTagName ('SubClass')
- curclass = self.classes[self.subclass_index]
- for cl in cls:
- curclass.subclasses += [PPSSubClass ().parse (cl)]
-
- def get_class_index (self, clsid):
- i = 0
- for cls in self.ppslist.getClasses():
- if cls.id == clsid:
- return i
- i += 1
- return -1
-
- def get_subclass_index (self, clsindex, subclsid):
- return -1
-
- def parse_films (self, res, clsid, subclsid):
- if not res:
- return []
- xmldoc = minidom.parseString (res)
- data = xmldoc.getElementsByTagName ('FilmData')
- if not data:
- return []
- films = data[0].getElementsByTagName ('Film')
- if not films:
- return []
-
-
- result = []
- for film in films:
- result += [PPSFilm ().parse (film)]
-
- return result
-
- def get_movie_class (self, clsid, subclsid):
- classes = self.ppslist.getClasses()
- clsindex = self.get_class_index (clsid)
- cls = classes[clsindex]
- subcls = None
- return cls, subcls
-
- def films_disk_name (self, clsid, subclsid):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- subcls = cls
- filename = 'films' + '-' + str(clsid) + '-' + str(subclsid)
- filename += '-' + str(subcls.contentnum) + '-' + str(subcls.page)
- filename += '.xml'
- return os.path.join (pps_cache_dir, "xmls", filename)
-
- def store_films_to_disk (self, clsid, subclsid, res):
- filename = self.films_disk_name (clsid, subclsid)
- #print 'writing', filename
- f = file (filename, 'wb')
- f.write (res)
- f.close ()
-
- def load_films_from_disk (self, url, callback, clsid, subclsid, count):
- filename = self.films_disk_name (clsid, subclsid)
- if not os.access (filename, os.R_OK):
- return False
-
- #print 'reading', filename
- try:
- st = os.stat (filename)
- now = time.time ()
- if now - st.st_ctime > FILM_MAX_CACHED_TIME:
- os.unlink (filename)
- return None
- except OSError:
+ def get_movie_class (self, class_path):
+ def find_class (classes, clsid):
+ for cls in classes:
+ if cls.id == clsid:
+ return cls
return None
- try:
- res = file(filename, 'rb').read ()
- except:
- return False
- callback (res, clsid, subclsid, count, False)
- return True
-
- def purge_cached_films (self, clsid, subclsid):
- import glob
-
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
- filename = 'films' + '-' + str(clsid) + '-' + str(subclsid)
- filename += '-*' + '.xml'
- pattern = os.path.join (pps_cache_dir, "xmls", filename)
- for f in glob.glob (pattern):
- os.unlink (f)
-
- def purage_outdated_films (self):
- import glob
+ if not class_path:
+ return None
+ classes = self.ppslist.getClasses()
+ return find_class (classes, class_path[0])
- filename = '*.xml'
- pattern = os.path.join (pps_cache_dir, "xmls", filename)
- for f in glob.glob (pattern):
- try:
- st = os.stat (f)
- now = time.time ()
- if 'films' in f:
- limit = FILMS_MAX_CACHED_TIME
- else:
- limit = CATEGORY_MAX_CACHED_TIME
- if now - st.st_ctime > limit:
- #print 'removing outdated ', f
- os.unlink (f)
- except OSError, e:
- print 'Failed to remove ', f, e
-
- def download_films (self, callback, clsid, subclsid, page, count):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- subcls = cls
+ def download_films (self, callback, class_path, page, count):
+ subcls = self.get_movie_class (class_path)
thread = ProcessThread (None, self.__fetch_films,
- callback, clsid, subclsid,
+ callback, class_path,
page, count)
thread.start()
- def __fetch_films(self, dummy, clsid, subclsid, page, *args):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- subcls = cls
- if cls.id != CATEGORY_ID_SEARCH:
- return self.ppslist.fetchMovieList(cls, page)
- return self.ppslist.searchMovieList(cls.keyword, page)
-
- def fetch_films (self, clsid, subclsid):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- subcls = cls
+ def __fetch_films(self, dummy, class_path, page, *args):
+ subcls = self.get_movie_class (class_path)
+ if subcls.id != CATEGORY_ID_SEARCH:
+ return self.ppslist.fetchMovieList(subcls, page)
+ return self.ppslist.searchMovieList(subcls.keyword, page)
+ def fetch_films (self, class_path):
+ subcls = self.get_movie_class (class_path)
subcls.fetching_films = True
#print subcls, subcls.page
- self.download_films (self.on_films_fetched, clsid, subclsid,
+ self.download_films (self.on_films_fetched, class_path,
self.films_page, self.films_count)
- def on_cat_treeview_row_activated(self, treeview, path, view_column, data=None):
+ def on_category_row_activated(self, treeview, path, view_column,
+ data = None):
model, rows = treeview.get_selection ().get_selected_rows ()
iter = model.get_iter (rows[0])
title = model.get_value (iter, 3)
classid = model.get_value (iter, 0)
- subclassid = model.get_value (iter, 2)
- #print title, classid, subclassid
+ class_path = (classid,)
+ #print title, class_path
+
self.films_page = 0
- self.show_films (classid, subclassid)
+ self.show_films (class_path)
self.notebook.set_current_page (1)
def setup_categories (self):
@@ -855,7 +697,7 @@ class PPStream (totem.Plugin):
self.treeview[treeview_name] = treeview
treeview.set_model (self.liststore[treeview_name])
- treeview.connect("row_activated", self.on_cat_treeview_row_activated)
+ treeview.connect("row_activated", self.on_category_row_activated)
self.categories_count = 0
@@ -866,8 +708,7 @@ class PPStream (totem.Plugin):
return
iter = model.get_iter (rows[0])
- clsid = model.get_value (iter, 4)
- subclsid = model.get_value (iter, 5)
+ class_path = eval(model.get_value (iter, 4))
for row in rows:
iter = model.get_iter (row)
@@ -877,10 +718,9 @@ class PPStream (totem.Plugin):
filtermodel = model.get_model ()
else:
filtermodel = model
- clsid = filtermodel.get_value (iter, 4)
- subclsid = filtermodel.get_value (iter, 5)
- self.add_favorites (clsid, subclsid,
- filtermodel.get_path (iter)[0], False)
+ class_path = eval(filtermodel.get_value (iter, 4))
+ self.add_favorites (class_path,
+ filtermodel.get_path (iter)[0], False)
self.save_favorites ()
self.refresh_favorites ()
@@ -898,10 +738,9 @@ class PPStream (totem.Plugin):
filtermodel = model.get_model ()
else:
filtermodel = model
- clsid = filtermodel.get_value (iter, 4)
- subclsid = filtermodel.get_value (iter, 5)
- self.remove_favorites (clsid, subclsid,
- filtermodel.get_path (iter)[0], False)
+ class_path = eval(filtermodel.get_value (iter, 4))
+ self.remove_favorites (class_path,
+ filtermodel.get_path (iter)[0], False)
self.save_favorites ()
self.refresh_favorites ()
@@ -918,7 +757,9 @@ class PPStream (totem.Plugin):
def load_favorites (self):
self.favorites = ppslist.PPSClass ()
+ self.favorites.id = CATEGORY_ID_FAVORITES
self.favorites.title = _('Favorites')
+ self.fetching_films = False
filename = os.path.join (pps_cache_dir, 'favorites.pickle')
if not os.path.exists (filename):
@@ -950,10 +791,8 @@ class PPStream (totem.Plugin):
except:
pass
- def add_favorites (self, clsid, subclsid, index, update = True):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ def add_favorites (self, class_path, index, update = True):
+ subcls = self.get_movie_class (class_path)
films = subcls.getMovies()
film = films[index]
if film in self.favorites.getMovies():
@@ -965,10 +804,8 @@ class PPStream (totem.Plugin):
self.refresh_favorites ()
self.save_favorites ()
- def remove_favorites (self, clsid, subclsid, index, update = False):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ def remove_favorites (self, class_path, index, update = False):
+ subcls = self.get_movie_class (class_path)
films = subcls.getMovies()
film = films[index]
#print self.favorites.films, film
@@ -993,12 +830,12 @@ class PPStream (totem.Plugin):
if self.movie_class_path == ():
return
- clsid, subclsid = self.movie_class_path
- if (clsid, subclsid) != (CATEGORY_ID_FAVORITES, 0):
+ class_path = self.movie_class_path
+ if class_path != (CATEGORY_ID_FAVORITES):
return
self.movie_class_path = ()
- self.show_films (clsid, subclsid, False, True)
+ self.show_films (class_path, False, True)
def setup_recent (self):
self.load_recent ()
@@ -1009,6 +846,7 @@ class PPStream (totem.Plugin):
self.recent = ppslist.PPSClass ()
self.recent.id = CATEGORY_ID_RECENT;
self.recent.title = _('Recent')
+ self.recent.fetching_films = False
filename = os.path.join (pps_cache_dir, 'recent.pickle')
if not os.path.exists (filename):
@@ -1040,10 +878,8 @@ class PPStream (totem.Plugin):
except:
pass
- def add_recent (self, clsid, subclsid, index):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ def add_recent (self, class_path, index):
+ subcls = self.get_movie_class (class_path)
film = subcls.getMovies()[index]
liststore_name = 'films'
@@ -1087,18 +923,19 @@ class PPStream (totem.Plugin):
if self.movie_class_path == ():
return
- clsid, subclsid = self.movie_class_path
- if (clsid, subclsid) != (CATEGORY_ID_RECENT, 0):
+ class_path = self.movie_class_path
+ if class_path != (CATEGORY_ID_RECENT):
return
self.movie_class_path = ()
- self.show_films (clsid, subclsid, False, True)
+ self.show_films (class_path, False, True)
def setup_search (self):
self.search = ppslist.PPSClass()
self.search.id = CATEGORY_ID_SEARCH
self.search.title = _('Search result')
self.search.keyword = ''
+ self.search.fetching_films = False
def fill_all_categories (self):
treeview_name = 'categories'
@@ -1147,9 +984,7 @@ class PPStream (totem.Plugin):
def update_current_category (self):
if not self.movie_class_path:
return
- cls, subcls = self.get_movie_class(*self.movie_class_path)
- if not subcls:
- subcls = cls
+ subcls = self.get_movie_class(self.movie_class_path)
self.update_category (subcls)
def gettipfromfilm (self, film):
@@ -1174,19 +1009,20 @@ class PPStream (totem.Plugin):
return unescape_xml (tip)
- def on_image_retrieved (self, pixbuf, film, iter, clsid, subclsid, count):
+ def on_image_retrieved (self, pixbuf, film, iter, class_path, count):
treeview_name = 'films'
- treeview = self.liststore[treeview_name]
+ liststore = self.liststore[treeview_name]
film.pixbuf = pixbuf
try:
### check whether the treeview has been cleared.
- if self.movie_class_path == (clsid, subclsid) and self.films_count == count:
+ if self.movie_class_path == class_path and self.films_count == count:
if self.configs['show_posters']:
- treeview.set (iter, 0, pixbuf)
+ liststore.set (iter, 0, pixbuf)
else:
print 'not showing posters'
- except:
+ except Exception, e:
+ print 'Failed to loading posters:', class_path, e
pass
def recode_mrl (self, url):
@@ -1204,7 +1040,7 @@ class PPStream (totem.Plugin):
qs = ''
return path + qs
- def storelist_append_film (self, treeview, film, clsid, subclsid, pos = -1):
+ def storelist_append_film (self, treeview, film, class_path, pos = -1):
files = film.getFiles()
#if not film.getFiles():
# return
@@ -1220,15 +1056,20 @@ class PPStream (totem.Plugin):
pixbuf = None
url = self.recode_mrl (origurl)
if pos == -1:
- it = treeview.append ([pixbuf, film.title, url, tip, clsid, subclsid, origurl])
+ it = treeview.append ([pixbuf, film.title, url, tip,
+ repr(class_path), origurl])
else:
it = treeview.insert (0)
treeview.set (it,
- 0, pixbuf, 1, film.title, 2, url, 3, tip,
- 4, clsid, 5, subclsid, f.url)
+ 0, pixbuf,
+ 1, film.title,
+ 2, url,
+ 3, tip,
+ 4, repr(class_path),
+ 5, f.url)
if not film.pixbuf and film.smallimage and self.configs['show_posters']:
self.retrieveimage.retrieve (film.smallimage, self.on_image_retrieved,
- film, it, clsid, subclsid,
+ film, it, class_path,
self.films_count)
film.model_path = treeview.get_path(it)
@@ -1265,63 +1106,58 @@ class PPStream (totem.Plugin):
self.fill_files(film)
self.films_update_files_status()
- def fill_all_films (self, clsid, subclsid):
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ def fill_all_films (self, class_path):
+ subcls = self.get_movie_class (class_path)
self.set_page_max(subcls.getMaxPage())
treeview_name = 'films'
liststore = self.liststore[treeview_name]
for film in subcls.getPage(self.films_page):
- self.storelist_append_film (liststore, film, clsid, subclsid)
+ self.storelist_append_film (liststore, film, class_path)
self.update_category (subcls)
- def fill_films (self, films, clsid, subclsid):
- if self.movie_class_path != (clsid, subclsid):
+ def fill_films (self, films, class_path):
+ if self.movie_class_path != class_path:
return
treeview_name = 'films'
liststore = self.liststore[treeview_name]
for film in films:
- self.storelist_append_film (liststore, film, clsid, subclsid)
+ self.storelist_append_film (liststore, film, class_path)
self.update_current_category ()
- def refetch_films (self, clsid = None, subclsid = None):
- if clsid is None and subclsid is None:
- clsid, subclsid = self.movie_class_path
+ def refetch_films (self, class_path = None):
+ if class_path is None:
+ class_path = self.movie_class_path
- self.purge_cached_films (clsid, subclsid)
self.retrieveimage.cancel_tasks ()
self.movie_class_path = ()
- self.show_films (clsid, subclsid, True)
+ self.show_films (class_path, True)
- def show_films (self, clsid, subclsid, force = False, cancel = True):
+ def show_films (self, class_path, force = False, cancel = True):
+ #print class_path, force, cancel
### force -- refetch movie list from server
### cancel -- discard the current movie list
- if self.movie_class_path == (clsid, subclsid) and not force:
+ if self.movie_class_path == class_path and not force:
return
- self.movie_class_path = (clsid, subclsid)
### cancel current fetching thread
if cancel:
self.films_count += 1
if self.movie_class_path != ():
- cls, subcls = self.get_movie_class (*self.movie_class_path)
- subcls = cls
+ subcls = self.get_movie_class (self.movie_class_path)
subcls.fetching_films = False
- self.movie_class_path = (clsid, subclsid)
+ self.movie_class_path = class_path
if not self.configs['show_posters']:
self.retrieveimage.cancel_tasks ()
self.clear_pages (['films', 'files'])
- cls, subcls = self.get_movie_class (clsid, subclsid)
- subcls = cls
+ subcls = self.get_movie_class (class_path)
### reset movie list(except the favorites/recent list)
if force:
@@ -1329,15 +1165,15 @@ class PPStream (totem.Plugin):
if cancel or (not subcls.fetching_films and \
not self.retrieveimage.is_busy ()):
- self.add_progress_callback (clsid, subclsid,
+ self.add_progress_callback (class_path,
self.films_count)
### fill all loaded films
self.set_current_page(self.films_page + 1)
- self.fill_all_films (clsid, subclsid)
+ self.fill_all_films (class_path)
if not len(subcls.getPage(self.films_page)) and \
not subcls.fetching_films:
- self.fetch_films (clsid, subclsid)
+ self.fetch_films (class_path)
def on_films_visible_func (self, model, iter):
terms = self.search_terms
@@ -1395,8 +1231,6 @@ class PPStream (totem.Plugin):
selection = treeview.get_selection ()
selection.connect ("changed", self.on_films_selection_changed)
- self.purage_outdated_films ()
-
def on_add_to_playlist (self, treeview):
### add selected film to recent list
treeview_name = 'films'
@@ -1563,12 +1397,9 @@ class PPStream (totem.Plugin):
if type (model) is gtk.TreeModelFilter:
iter = model.convert_iter_to_child_iter (iter)
model = model.get_model ()
- clsid = model.get_value (iter, 4)
- subclsid = model.get_value (iter, 5)
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ class_path = eval(model.get_value (iter, 4))
+ subcls = self.get_movie_class (class_path)
index = model.get_path(iter)[0]
movie = subcls.getPage(self.films_page)[index]
@@ -1593,12 +1424,9 @@ class PPStream (totem.Plugin):
if type (model) is gtk.TreeModelFilter:
iter = model.convert_iter_to_child_iter (iter)
model = model.get_model ()
- clsid = model.get_value (iter, 4)
- subclsid = model.get_value (iter, 5)
- cls, subcls = self.get_movie_class (clsid, subclsid)
- if not subcls:
- subcls = cls
+ class_path = eval(model.get_value (iter, 4))
+ subcls = self.get_movie_class (class_path)
index = model.get_path(iter)[0]
movie = subcls.getPage(self.films_page)[index]
@@ -1609,22 +1437,20 @@ class PPStream (totem.Plugin):
if not url:
url = movie.getFiles()[0].url
model.set(iter, 2, self.recode_mrl(url))
- model.set(iter, 6, url)
+ model.set(iter, 5, url)
self.add_to_favorites_button.set_sensitive(all_files_fetched)
def on_first_page_clicked(self, *args):
if self.movie_class_path == ():
return
- cls, subcls = self.get_movie_class(*self.movie_class_path)
- if not subcls:
- subcls = cls
+ subcls = self.get_movie_class(self.movie_class_path)
if self.films_page == 0:
return
self.films_page = 0
- self.show_films(*self.movie_class_path, force = True)
+ self.show_films(self.movie_class_path, force = True)
def on_prev_page_clicked(self, *args):
if self.movie_class_path == ():
@@ -1638,22 +1464,20 @@ class PPStream (totem.Plugin):
def on_next_page_clicked(self, *args):
if self.movie_class_path == ():
return
- cls, subcls = self.get_movie_class(*self.movie_class_path)
- if not subcls:
- subcls = cls
+ subcls = self.get_movie_class(self.movie_class_path)
if self.films_page >= subcls.getMaxPage() - 1:
return
self.films_page += 1
- self.show_films(*self.movie_class_path, force = True)
+ self.show_films(self.movie_class_path, force = True)
def on_last_page_clicked(self, *args):
if self.movie_class_path == ():
return
- cls, subcls = self.get_movie_class(*self.movie_class_path)
- if not subcls:
- subcls = cls
+
+ subcls = self.get_movie_class(self.movie_class_path)
+
if self.films_page == subcls.getMaxPage() - 1:
return
self.films_page = subcls.getMaxPage() - 1
@@ -1664,9 +1488,7 @@ class PPStream (totem.Plugin):
if self.movie_class_path == ():
return
- cls, subcls = self.get_movie_class(*self.movie_class_path)
- if not subcls:
- subcls = cls
+ subcls = self.get_movie_class(self.movie_class_path)
page = self.which_page_button.get_value_as_int() - 1
if page >= subcls.getMaxPage():
@@ -1674,7 +1496,7 @@ class PPStream (totem.Plugin):
if page == self.films_page:
return
self.films_page = page
- self.show_films(*self.movie_class_path, force = True)
+ self.show_films(self.movie_class_path, force = True)
def set_page_max(self, max_page):
adjustment = self.which_page_button.get_adjustment()
@@ -1720,7 +1542,7 @@ class PPStream (totem.Plugin):
elif self.current_treeview_name == 'films':
if self.movie_class_path == ():
self.refresh_button.set_sensitive (False)
- elif self.movie_class_path == (0, 0):
+ elif self.movie_class_path == (CATEGORY_ID_FAVORITES,):
self.remove_from_favorites_button.set_sensitive (True)
else:
self.refresh_button.set_sensitive (True)
@@ -1759,9 +1581,7 @@ class PPStream (totem.Plugin):
self.progress_bar.hide ()
return True
- cls, subcls = self.get_movie_class (*self.movie_class_path)
- if not subcls:
- subcls = cls
+ subcls = self.get_movie_class (self.movie_class_path)
if subcls.fetching_films:
self.progress_bar.pulse()
progressstr = '(%d/%d)' % (self.films_page + 1, subcls.max_page)
@@ -1791,14 +1611,14 @@ class PPStream (totem.Plugin):
return True
- def on_update_progress_bar (self, clsid, subclsid, count):
- if self.movie_class_path == (clsid, subclsid) and self.films_count == count:
+ def on_update_progress_bar (self, class_path, count):
+ if self.movie_class_path == class_path and self.films_count == count:
return self.update_progress_bar ()
return False
- def add_progress_callback (self, clsid, subclsid, count):
+ def add_progress_callback (self, class_path, count):
gobject.timeout_add (350, self.on_update_progress_bar,
- clsid, subclsid, count)
+ class_path, count)
def on_films_row_activated (self, treeview, path, column):
pass
@@ -1811,18 +1631,15 @@ class PPStream (totem.Plugin):
iter = model.convert_iter_to_child_iter (iter)
model = model.get_model ()
- clsid = model.get_value (iter, 4)
- subclsid = model.get_value (iter, 5)
+ class_path = eval(model.get_value (iter, 4))
+ subcls = self.get_movie_class(class_path)
- cls, subcls = self.get_movie_class(clsid, subclsid)
- if not subcls:
- subcls = cls
film = subcls.getPage(self.films_page)[path[0]]
files = film.getFiles()
if not files:
return False
- self.add_recent (clsid, subclsid,
+ self.add_recent (class_path,
model.get_path (iter)[0])
return True
@@ -1880,9 +1697,9 @@ class PPStream (totem.Plugin):
self.cell_video_renderer.set_property ('use_placeholder', show)
if self.movie_class_path == ():
return
- clsid, subclsid = self.movie_class_path
+ class_path = self.movie_class_path
self.movie_class_path = ()
- self.show_films (clsid, subclsid, False, False)
+ self.show_films (class_path, False, False)
def sync_config (self):
for key in self.input_configs.keys ():
@@ -1973,3 +1790,443 @@ class PPStream (totem.Plugin):
button = self.config_builder.get_object ("pps_config_compatible")
button.set_active (self.configs['compatible'])
button.connect ("toggled", self.on_config_checkbutton_toggle, 'compatible')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/totem/plugin/ppstream.ui b/totem/plugin/ppstream.ui
index 1e68988..511db9a 100644
--- a/totem/plugin/ppstream.ui
+++ b/totem/plugin/ppstream.ui
@@ -38,10 +38,8 @@
<column type="gchararray"/>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
- <!-- column-name Class -->
- <column type="gint"/>
- <!-- column-name Subclass -->
- <column type="gint"/>
+ <!-- column-name Class path -->
+ <column type="gchararray"/>
<!-- column-name OrigMRL -->
<column type="gchararray"/>
</columns>