def update_folder(self, details, folder): """ :type details: Details :type folder: Folder """ media_path = self.get_media_path(details.section, details.title) if not direxists(media_path): self.log.info("Creating library folder: %s", media_path) xbmcvfs.mkdir(media_path) else: self.log.info("Updating library folder: %s", media_path) self.storage[folder.id] = (details.media_id, media_path, details.section) files = folder.files """ :type : list of File """ for f in files: file_path = os.path.join(media_path, self.get_file_name(folder.id, f.title)) if not xbmcvfs.exists(file_path): self.log.info("Adding file: %s", file_path) fp = xbmcvfs.File(file_path, 'w') can_mark_watched = len(files) == 1 and not details.section.is_series() url = plugin.url_for('play_file', section=details.section.filter_val, media_id=details.media_id, url=f.link, title=f.title, can_mark_watched=int(can_mark_watched)) fp.write(ensure_str(url)) fp.close() return media_path
def url(self): if self._url is None: if self.has_file_name(): self._url = urlparse.urljoin('file:', urllib.pathname2url(ensure_str(self.file_name))) else: raise TorrentError(32016, "Torrent URL is unknown") return self._url
def url(self): if self._url is None: if self.has_file_name(): self._url = urlparse.urljoin( 'file:', urllib.pathname2url(ensure_str(self.file_name))) else: raise TorrentError(32016, "Torrent URL is unknown") return self._url
def bookmark_context_menu(media_id, section, title): bookmarks = container.bookmarks() if media_id in bookmarks: return [(lang(40307), actions.background(plugin.url_for('delete_bookmark', media_id=media_id, section=section.filter_val)))] else: return [(lang(40306), actions.background(plugin.url_for('add_bookmark', media_id=media_id, section=section.filter_val, title=ensure_str(title))))]
def authorize(self): with Timer(logger=self.log, name='Authorization'): self.fetch(self.BASE_URL + '/browse.php') doc = self.fetch(self.LOGIN_URL, params={'referer': 'http://www.lostfilm.tv/'}, data={'login': self.login, 'password': self.password}) action_url = doc.find('form').attr('action') names = doc.find('input', {'type': 'hidden'}).attrs('name') values = doc.find('input', {'type': 'hidden'}).attrs('value') params = zip(names, [ensure_str(s) for s in values]) if not action_url or not names or not values: self.log.debug(doc) raise ScraperError(32003, "Authorization failed", check_settings=True) self.fetch(action_url, data=params) self.session.cookies['hash'] = self.authorization_hash if not self.authorized(): raise ScraperError(32003, "Authorization failed", check_settings=True)
def encoded_query(self): return dict((k, ensure_str(v)) for k, v in self.query.iteritems())