rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
return value * 3.0
return value * widgetconst.MAX_VOLUME
def to_miro_volume(value): """Convert from 0 to 1.0 to 0.0 to MAX_VOLUME. """ if value == 0: return 0.0 return value * 3.0
value = (value / 3.0)
value = (value / widgetconst.MAX_VOLUME)
def to_gtk_volume(value): """Convert from 0.0 to MAX_VOLUME to 0 to 1.0. """ if value > 0.0: value = (value / 3.0) return value
self.setup_subtitles()
self.enable_subtitle_track(1) handle_successful_select()
def select_subtitle_file(self, item, sub_path, handle_successful_select): sub_path = sub_path.encode('utf-8') try: sub_path = copy_subtitle_file(sub_path, item.video_path) except WindowsError: # FIXME - need a better way to deal with this. when this # happens, then the subtitle file isn't in the right place # for VLC ...
video_id = params['v'][0]
try: video_id = params['v'][0] except IndexError: pass
def _scrape_youtube_url(url, callback): check_u(url) components = urlparse.urlsplit(url) params = cgi.parse_qs(components[3]) if components[2] == u'/watch' and 'v' in params: video_id = params['v'][0] elif components[2].startswith('/v/'): video_id = re.compile(r'/v/([\w-]+)').match(components[2]).group(1) else: loggi...
video_id = re.compile(r'/v/([\w-]+)').match(components[2]).group(1) else:
m = re.compile(r'/v/([\w-]+)').match(components[2]) if m is not None: video_id = m.group(1) if video_id is None:
def _scrape_youtube_url(url, callback): check_u(url) components = urlparse.urlsplit(url) params = cgi.parse_qs(components[3]) if components[2] == u'/watch' and 'v' in params: video_id = params['v'][0] elif components[2].startswith('/v/'): video_id = re.compile(r'/v/([\w-]+)').match(components[2]).group(1) else: loggi...
self._recaclulate_hidden_items()
self._recalculate_hidden_items()
def set_new_only(self, new_only): """Set if only new items are to be displayed (default False).""" self.new_only = new_only self._recaclulate_hidden_items()
self._recaclulate_hidden_items()
self._recalculate_hidden_items()
def view_all(self): self.unwatched_only = False self.non_feed_only = False self._recaclulate_hidden_items()
self._recaclulate_hidden_items()
self._recalculate_hidden_items()
def toggle_unwatched_only(self): self.unwatched_only = not self.unwatched_only self._recaclulate_hidden_items()
self._recaclulate_hidden_items()
self._recalculate_hidden_items()
def toggle_non_feed(self): self.non_feed_only = not self.non_feed_only self._recaclulate_hidden_items()
self._recaclulate_hidden_items() def _recaclulate_hidden_items(self):
self._recalculate_hidden_items() def _recalculate_hidden_items(self):
def set_search_text(self, search_text): self._search_text = search_text self._recaclulate_hidden_items()
if desc is not None:
if desc:
def _disable_video(self): desc = libvlc.libvlc_video_get_track_description( self.media_player, self.exc.ref()) self.exc.check() # the 1st description should be "Disable" if desc is not None: track_id = desc.contents.id libvlc.libvlc_track_description_release(desc) libvlc.libvlc_video_set_track(self.media_player, track_...
def _youtube_get_first_successful(info, current_url, urls, callback, title): if isinstance(info, httpclient.UnexpectedStatusCode): if info.code != 404: _youtube_errback(info, callback) return if len(urls) == 0: callback(None) return current_url, urls = urls[0], urls[1:] logging.debug("youtube download: trying %s", c...
def _youtube_get_first_successful(info, current_url, urls, callback, title): if isinstance(info, httpclient.UnexpectedStatusCode): if info.code != 404: _youtube_errback(info, callback) return if len(urls) == 0: callback(None) return current_url, urls = urls[0], urls[1:] logging.debug("youtube download: trying %s", c...
token = params['token'][0]
fmt_url_map = params["fmt_url_map"][0].split(",") fmt_url_map = dict([mem.split("|") for mem in fmt_url_map])
def _youtube_callback_step2(info, video_id, callback): try: body = info['body'] params = cgi.parse_qs(body) if params.get("status", [""])[0] == "fail": logging.info("youtube download failed because: %s", params.get("reason", ["unknown"])[0]) callback(None) return token = params['token'][0] title = unicode(params.get(...
lodef_url = u"http://www.youtube.com/get_video?video_id=%s&t=%s&eurl=&el=embedded&ps=default" % (video_id, token) urls = [ lodef_url + u"&fmt=22", lodef_url + u"&fmt=18", lodef_url] logging.debug("youtube download: trying %s", urls[0]) httpclient.grab_headers( urls[0], lambda x: _youtube_get_first_successful(x, urls[...
for fmt, content_type in [("22", u"video/mp4"), ("18", u"video/mp4"), ("5", u"video/x-flv")]: if fmt in fmt_url_map: new_url = fmt_url_map[fmt] logging.debug("youtube download: trying %s", new_url) callback( unicode(new_url), content_type=content_type, title=title) return _youtube_errback(info, callback)
def _youtube_callback_step2(info, video_id, callback): try: body = info['body'] params = cgi.parse_qs(body) if params.get("status", [""])[0] == "fail": logging.info("youtube download failed because: %s", params.get("reason", ["unknown"])[0]) callback(None) return token = params['token'][0] title = unicode(params.get(...
elif isinstance(thumb, unicode): return thumb.decode('ascii', 'replace')
def _get_element_thumbnail(self, element): try: thumb = element["thumbnail"] except KeyError: return None if isinstance(thumb, str): return thumb elif isinstance(thumb, unicode): return thumb.decode('ascii', 'replace') try: return thumb["url"].decode('ascii', 'replace') except (KeyError, AttributeError): return None
except (KeyError, AttributeError):
except (KeyError, AttributeError, UnicodeEncodeError, UnicodeDecodeError):
def _get_element_thumbnail(self, element): try: thumb = element["thumbnail"] except KeyError: return None if isinstance(thumb, str): return thumb elif isinstance(thumb, unicode): return thumb.decode('ascii', 'replace') try: return thumb["url"].decode('ascii', 'replace') except (KeyError, AttributeError): return None
self.model = VideoConversionsTableModel()
self.iter_map = dict() self.model = widgetset.TableModel('object')
def build_widget(self): image_path = resources.path("images/icon-conversions_large.png") icon = imagepool.get(image_path) titlebar = VideoConversionsTitleBar(_("Conversions"), icon) self.widget.pack_start(titlebar)
self.model.add_task(task)
self.iter_map[task.key] = self.model.append(task)
def handle_task_list(self, running_tasks, pending_tasks): for task in running_tasks: self.model.add_task(task) for task in pending_tasks: self.model.add_task(task) self.table.model_changed()
self.model.add_task(task)
self.iter_map[task.key] = self.model.append(task)
def handle_task_added(self, task): self.model.add_task(task) self.table.model_changed()
self.model.remove_task(task) self.table.model_changed()
self.handle_task_completed(task)
def handle_task_canceled(self, task): self.model.remove_task(task) self.table.model_changed()
self.model.update_task(task)
itr = self.iter_map[task.key] self.model.update_value(itr, 0, task)
def handle_task_progress(self, task): self.model.update_task(task) self.table.model_changed()
self.model.remove_task(task)
itr = self.iter_map.pop(task.key) self.model.remove(itr)
def handle_task_completed(self, task): self.model.remove_task(task) self.table.model_changed()
class VideoConversionsTableModel(widgetset.TableModel): def __init__(self): widgetset.TableModel.__init__(self, 'object') def add_task(self, task): self.append(task) def update_task(self, task): itr = self._find_task(task) if itr is not None: self.update(itr, task) def remove_task(self, task): itr = self._find_task...
def __init__(self, model): widgetset.TableView.__init__(self, model) self.set_show_headers(False)
'includes': 'cairo, pango, pangocairo, atk, gobject, gio, libtorrent',
'includes': ('cairo, pango, pangocairo, atk, gobject, ' 'gio, libtorrent, mutagen'),
def add_directory(self, dirname): for root, dirs, files in os.walk(os.path.join(self.dist_dir, dirname)): for name in files: self.add_file(os.path.join(root, name))
self.enable_subtitle_track(1)
def select_subtitle_file(self, item, sub_path, handle_successful_select): sub_path = sub_path.encode('utf-8') try: sub_path = copy_subtitle_file(sub_path, item.video_path) except WindowsError: # FIXME - need a better way to deal with this. when this # happens, then the subtitle file isn't in the right place # for VLC ...
def set_y(self, x):
def set_y(self, y):
def set_y(self, x): self.nsrect.origin.x = y
except UnicodeDecodeError:
except (UnicodeDecodeError, LookupError):
def _to_utf8_bytes(s, encoding=None): """Takes a string and do whatever needs to be done to make it into a UTF-8 string. If a Unicode string is given, it is just encoded in UTF-8. Otherwise, if an encoding hint is given, first try to decode the string as if it were in that encoding; if that fails (or the hint isn't giv...
'url': unicode(value[0], 'utf8')}
'url': value[0].decode('utf-8', 'replace')}
def get_subscriptions_from_query(subscription_type, query): subscriptions = [] # the query string shouldn't be a unicode. if we pass it in as a # unicode then parse_qs returns unicode values which aren't # properly converted and then we end up with boxes instead of ' # and " characters. query = str(query) parsed_query...
value = unicode(parsed_query[key3][0], "utf-8")
value = parsed_query[key3][0].decode("utf-8", 'replace')
def get_subscriptions_from_query(subscription_type, query): subscriptions = [] # the query string shouldn't be a unicode. if we pass it in as a # unicode then parse_qs returns unicode values which aren't # properly converted and then we end up with boxes instead of ' # and " characters. query = str(query) parsed_query...
"stderr": subprocess.PIPE}
"stderr": subprocess.PIPE, "startupinfo": util.no_console_startupinfo()}
def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.output_path): self._log_progress("Removing existing output file (%s)...\n" % self.output_path) os.remove(self.output_path)
elif os.name == 'nt': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW kwargs["startupinfo"] = startupinfo
def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.output_path): self._log_progress("Removing existing output file (%s)...\n" % self.output_path) os.remove(self.output_path)
v = widget.get_text().strip()
v = widget.get_text().strip().encode('utf-8')
def text_changed(widget): v = widget.get_text().strip() if check_function != None: if not check_function(widget, v): return app.config.set(descriptor, v)
for d in dirp:
for d in dirs:
def dirfilt(root, dirs): """ Platform hook to filter out any directories that should not be descended into, root and dirs corresponds as per os.dirwalk() and same semantics for these objects apply. """ removelist = [] ws = NSWorkspace.sharedWorkspace() for d in dirp: if ws.isFilePackageAtPath_(os.path.join(root, d)): r...
DURATION_RE2 = re.compile('f2t ;duration: (.*);') PROGRESS_RE2 = re.compile('f2t ;position: (.*);') RESULT_RE2 = re.compile('f2t ;result: (.*);')
DURATION_RE2 = re.compile('f2t ;duration: ([^;]*);') PROGRESS_RE2 = re.compile('f2t ;position: ([^;]*);') RESULT_RE2 = re.compile('f2t ;result: ([^;]*);') def __init__(self, converter_info, item_info, target_folder): VideoConversionTask.__init__(self, converter_info, item_info, target_folder) self.platform = config.ge...
def monitor_progress(self, line): if self.duration is None: match = self.DURATION_RE.match(line) if match is not None: hours = match.group(1) minutes = match.group(2) seconds = match.group(3) frames = match.group(4) self.duration = int(hours) * 60 * 60 + int(minutes) * 60 + int(seconds) else: match = self.PROGRESS_RE.m...
match = self.RESULT_RE.match(line)
match = self.RESULT_RE1.match(line)
def monitor_progress(self, line): if line.startswith('f2t'): if self.duration is None: match = self.DURATION_RE2.match(line) if match is not None: self.duration = float(match.group(1)) match = self.PROGRESS_RE2.match(line) if match is not None: return float(match.group(1)) / self.duration match = self.RESULT_RE2.match(...
self.handle_crash_report(report)
call_on_ui_thread(lambda: self.handle_crash_report(report))
def exception_handler(self, typ, value, traceback): report = crashreport.format_crash_report("in frontend thread", exc_info=(typ, value, traceback), details=None) self.handle_crash_report(report)
libvlc.libvlc_media_player_set_drawable(
libvlc.libvlc_media_player_set_hwnd(
def __init__(self): plugin_dir = os.path.join(resources.appRoot(), 'vlc-plugins') self.exc = VLCException()
libvlc.libvlc_media_player_set_hwnd(self.media_player, 0, self.exc.ref())
libvlc.libvlc_media_player_set_hwnd( self.media_player, self._hidden_window.handle, self.exc.ref())
def unset_widget(self): libvlc.libvlc_media_player_set_hwnd(self.media_player, 0, self.exc.ref()) self.exc.check()
if self.player is not None:
if self.player_ready():
def notify_update(self): if self.player is not None: elapsed = self.player.get_elapsed_playback_time() total = self.player.get_total_playback_time() self.emit('playback-did-progress', elapsed, total)
if not self.open_successful or self.player is None:
if not self.player_ready():
def update_current_resume_time(self, resume_time=-1): if not self.open_successful or self.player is None: return item_info = self.playlist[self.position] if app.config.get(prefs.RESUME_VIDEOS_MODE): if resume_time == -1: resume_time = self.player.get_elapsed_playback_time() # if we are 95% of the way into the movie and...
default_track = self.get_enabled_subtitle_track() if default_track is None:
enabled_tracks = self.get_all_enabled_subtitle_tracks() if len(enabled_tracks) == 0:
def setup_subtitles(self, force_subtitles): if config.get(prefs.ENABLE_SUBTITLES) or force_subtitles: default_track = self.get_enabled_subtitle_track() if default_track is None: tracks = self.get_subtitle_tracks() if len(tracks) > 0: self.enable_subtitle_track(tracks[0]) else: self.disable_subtitles()
self.pipeline = gst.parse_launch('filesrc location="%s" ! decodebin ! ffmpegcolorspace ! video/x-raw-rgb,depth=24,bpp=24 ! fakesink signal-handoffs=True' % (filename,)) for sink in self.pipeline.sinks(): name = sink.get_name() factoryname = sink.get_factory().get_name() if factoryname == "fakesink": pad = sink.get_pad...
self.pipeline = gst.element_factory_make('playbin') self.videosink = gst.element_factory_make("fakesink", "videosink") self.pipeline.set_property("video-sink", self.videosink) self.audiosink = gst.element_factory_make("fakesink", "audiosink") self.pipeline.set_property("audio-sink", self.audiosink) self.thumbnail_pipe...
def __init__(self, filename, thumbnail_filename, callback):
def start_audio_only(self): self.audio_only = True self.pipeline = gst.parse_launch('filesrc location="%s" ! decodebin ! fakesink' % (self.filename,)) self.bus = self.pipeline.get_bus() self.bus.add_signal_watch() self.watch_id = self.bus.connect("message", self.on_bus_message) self.pipeline.set_state(gst.STATE_PAUS...
def __init__(self, filename, thumbnail_filename, callback):
if message.type == gst.MESSAGE_ERROR: gobject.idle_add(self.error_occurred) if message.type == gst.MESSAGE_TAG: taglist = message.parse_tag() if 'video-codec' in taglist: self.saw_video_tag = True if 'audio-codec' in taglist: self.saw_audio_tag = True
elif message.type == gst.MESSAGE_ERROR: gobject.idle_add(self.error_occurred) elif message.src == self.thumbnail_pipeline: if message.type == gst.MESSAGE_STATE_CHANGED: prev, new, pending = message.parse_state_changed() if new == gst.STATE_PAUSED: seek_result = self.thumbnail_pipeline.seek( 1.0, gst.FORMAT_TIME, gst.S...
def on_bus_message(self, bus, message): if message.src == self.pipeline: if message.type == gst.MESSAGE_STATE_CHANGED: prev, new, pending = message.parse_state_changed() if new == gst.STATE_PAUSED: gobject.idle_add(self.paused_reached) if message.type == gst.MESSAGE_ERROR: gobject.idle_add(self.error_occurred) if messa...
if self.grabit:
try:
def buffer_probe_handler_real(self, pad, buff, name): """Capture buffers as gdk_pixbufs when told to.""" if self.grabit: caps = buff.caps if caps is not None: filters = caps[0] self.width = filters["width"] self.height = filters["height"] timecode = self.pipeline.query_position(gst.FORMAT_TIME)[0] pixbuf = gtk.gdk.pixb...
if caps is not None: filters = caps[0] self.width = filters["width"] self.height = filters["height"] timecode = self.pipeline.query_position(gst.FORMAT_TIME)[0] pixbuf = gtk.gdk.pixbuf_new_from_data(buff.data, gtk.gdk.COLORSPACE_RGB, False, 8, self.width, self.height, self.width * 3)
if caps is None: self.success = False self.disconnect() self.done() return False filters = caps[0] width = filters["width"] height = filters["height"] timecode = self.thumbnail_pipeline.query_position(gst.FORMAT_TIME)[0] pixbuf = gtk.gdk.pixbuf_new_from_data( buff.data, gtk.gdk.COLORSPACE_RGB, False, 8, width, height,...
def buffer_probe_handler_real(self, pad, buff, name): """Capture buffers as gdk_pixbufs when told to.""" if self.grabit: caps = buff.caps if caps is not None: filters = caps[0] self.width = filters["width"] self.height = filters["height"] timecode = self.pipeline.query_position(gst.FORMAT_TIME)[0] pixbuf = gtk.gdk.pixb...
def handle_result(duration, success, type):
def make_verbose(): import logging logging.basicConfig(level=logging.INFO) def wrap_func(func): def _wrap_func(*args, **kwargs): logging.info("calling %s (%s) (%s)", func.__name__, repr(args), repr(kwargs)) return func(*args, **kwargs) return _wrap_func for mem in dir(Extractor): fun = Extractor.__dict__[mem] if calla...
def handle_result(duration, success, type): if duration != -1: print "Miro-Movie-Data-Length: %s" % (duration / 1000000) else: print "Miro-Movie-Data-Length: -1" if success: print "Miro-Movie-Data-Thumbnail: Success" else: print "Miro-Movie-Data-Thumbnail: Failure" print "Miro-Movie-Data-Type: %s" % type sys.exit(0)
print "Miro-Movie-Data-Type: %s" % type
print "Miro-Movie-Data-Type: %s" % media_type
def handle_result(duration, success, type): if duration != -1: print "Miro-Movie-Data-Length: %s" % (duration / 1000000) else: print "Miro-Movie-Data-Length: -1" if success: print "Miro-Movie-Data-Thumbnail: Success" else: print "Miro-Movie-Data-Thumbnail: Failure" print "Miro-Movie-Data-Type: %s" % type sys.exit(0)
if __name__ == "__main__": if len(sys.argv) < 3:
def main(argv): if len(argv) < 3:
def handle_result(duration, success, type): if duration != -1: print "Miro-Movie-Data-Length: %s" % (duration / 1000000) else: print "Miro-Movie-Data-Length: -1" if success: print "Miro-Movie-Data-Thumbnail: Success" else: print "Miro-Movie-Data-Thumbnail: Failure" print "Miro-Movie-Data-Type: %s" % type sys.exit(0)
extractor = Extractor(sys.argv[1], sys.argv[2], handle_result)
if "--verbose" in argv: make_verbose() argv.remove("--verbose") extractor = Extractor(argv[1], argv[2], handle_result)
def handle_result(duration, success, type): if duration != -1: print "Miro-Movie-Data-Length: %s" % (duration / 1000000) else: print "Miro-Movie-Data-Length: -1" if success: print "Miro-Movie-Data-Thumbnail: Success" else: print "Miro-Movie-Data-Thumbnail: Failure" print "Miro-Movie-Data-Type: %s" % type sys.exit(0)
if not self.player_ready():
if not self.player_ready() and resume_time == -1:
def update_current_resume_time(self, resume_time=-1): if not self.player_ready(): return item_info = self.playlist[self.position] if app.config.get(prefs.RESUME_VIDEOS_MODE): if resume_time == -1: resume_time = self.player.get_elapsed_playback_time() # if we are 95% of the way into the movie and less than 30 # seconds ...
self.process_handle = subprocess.Popen(args, executable=executable, bufsize=1,
args.insert(0, executable) self.process_handle = subprocess.Popen(args, bufsize=1,
def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.output_path): self._log_progress("Removing existing output file (%s)...\n" % self.output_path) os.remove(self.output_path) self.process_handle = subprocess.Popen(args, executab...
total = self.player.get_total_playback_time() if total is not None: self.emit('playback-did-progress', progress * total, total)
try: total = self.player.get_total_playback_time() if total is not None: self.emit('playback-did-progress', progress * total, total) except: pass
def seek_to(self, progress): self.player.seek_to(progress) total = self.player.get_total_playback_time() if total is not None: self.emit('playback-did-progress', progress * total, total)
self.pick_initial_filename(suffix="", torrent=True)
try: self.pick_initial_filename(suffix="", torrent=True) except (OSError, IOError): raise RuntimeError
def got_metainfo(self): # FIXME: If the client is stopped before a BT download gets # its metadata, we never run this. It's not a huge deal # because it only affects the incomplete filename if not self.restarting: try: metainfo = lt.bdecode(self.metainfo) # if we don't get valid torrent metadata back, the...
window = MainDialog(_('Edit Item'), _('Edit the metadata of this item.'))
window = MainDialog(_('Edit Item'), "")
def _run_dialog(iteminfo): """Creates and launches the item edit dialog. This dialog waits for the user to press "Apply" or "Cancel". Returns a dict of new name -> value. """ window = MainDialog(_('Edit Item'), _('Edit the metadata of this item.')) try: try: window.add_button(BUTTON_APPLY.text) window.add_button(BUTT...
grid.pack(lab, grid.ALIGN_LEFT) grid.pack(sec)
vbox = widgetset.VBox() vbox.pack_start(lab, True, padding=2) grid.pack(vbox, grid.ALIGN_LEFT) grid.pack(sec, grid.ALIGN_LEFT)
def _run_dialog(iteminfo): """Creates and launches the item edit dialog. This dialog waits for the user to press "Apply" or "Cancel". Returns a dict of new name -> value. """ window = MainDialog(_('Edit Item'), _('Edit the metadata of this item.')) try: try: window.add_button(BUTTON_APPLY.text) window.add_button(BUTT...
title = ' '.join(t2) return unicode(title)
title = u' '.join(t2) return title
def _filename_to_title(self, filename): title = os.path.basename(filename) title = title.rsplit('.', 1)[0] title = title.replace('_', ' ') title = title.lstrip('0123456789. -') t2 = [] for word in title.split(' '): t2.append(word.capitalize()) title = ' '.join(t2) return unicode(title)
if len(self.get_selection()) <= 1:
if ((app.config.get(prefs.PLAY_IN_MIRO) and len(self.get_selection()) <= 1)):
def _play_item_list(self, items, presentation_mode='fit-to-bounds'): playable = self.filter_playable_items(items) if len(playable) == 0: return if len(self.get_selection()) <= 1: # User has 0 or 1 items selected, if more items get added # to the item list, we should play them. item_list = self._playback_item_view().ite...
for item_view in self.all_item_views(): item_view.start_bulk_change()
def handle_item_list(self, message): """Handle an ItemList message meant for this ItemContainer.""" for item_view in self.all_item_views(): item_view.start_bulk_change() self.item_list_group.add_items(message.items) for item_view in self.all_item_views(): item_view.model_changed() self.on_initial_list()
for item_view in self.all_item_views(): item_view.model_changed()
def handle_item_list(self, message): """Handle an ItemList message meant for this ItemContainer.""" for item_view in self.all_item_views(): item_view.start_bulk_change() self.item_list_group.add_items(message.items) for item_view in self.all_item_views(): item_view.model_changed() self.on_initial_list()
class Test_gather_subtitles_files(MiroTestCase):
class Test_copy_subtitle_file(MiroTestCase):
def test_filename_possibilities(self): movie_file, sub_files = self.create_files( "foo.mov", ["foo.en.srt", "foo.en.sub", "foo.srt", "foo.sub"])
child.set_active(True)
child.set_sensitive(True)
def handle_subtitles(self, widget, event): tracks = [] menu = gtk.Menu()
return _("%(size)s gb", {"size": value})
return _("%(size)s GB", {"size": value})
def size_string(nbytes): # when switching from the enclosure reported size to the # downloader reported size, it takes a while to get the new size # and the downloader returns -1. the user sees the size go to -1B # which is weird.... better to return an empty string. if nbytes == -1 or nbytes == 0: return "" # FIXME...
return _("%(size)s mb", {"size": value})
return _("%(size)s MB", {"size": value})
def size_string(nbytes): # when switching from the enclosure reported size to the # downloader reported size, it takes a while to get the new size # and the downloader returns -1. the user sees the size go to -1B # which is weird.... better to return an empty string. if nbytes == -1 or nbytes == 0: return "" # FIXME...
return _("%(size)s kb", {"size": value})
return _("%(size)s KB", {"size": value})
def size_string(nbytes): # when switching from the enclosure reported size to the # downloader reported size, it takes a while to get the new size # and the downloader returns -1. the user sees the size go to -1B # which is weird.... better to return an empty string. if nbytes == -1 or nbytes == 0: return "" # FIXME...
return _("%(size)s b", {"size": nbytes})
return _("%(size)s B", {"size": nbytes})
def size_string(nbytes): # when switching from the enclosure reported size to the # downloader reported size, it takes a while to get the new size # and the downloader returns -1. the user sees the size go to -1B # which is weird.... better to return an empty string. if nbytes == -1 or nbytes == 0: return "" # FIXME...
temp_dir = tempfile.mkdtemp("miro-conversion")
temp_dir = utils.FilenameType(tempfile.mkdtemp("miro-conversion"))
def build_output_paths(item_info, target_folder, converter_info): """Returns final_output_path and temp_output_path. """ input_path = item_info.video_path temp_dir = tempfile.mkdtemp("miro-conversion") title = utils.unicode_to_filename(item_info.name, temp_dir) if not title or not title.strip(): title = os.path.basenam...
print 'TRYING TO OPEN %s' % osfilename
def get_movie_from_file(self, path): osfilename = utils.filename_type_to_os_filename(path) print 'TRYING TO OPEN %s' % osfilename try: print 'TYPE', type(path) print path.urlize() url = NSURL.URLWithString_(path.urlize()) print 'URL', url except: url = NSURL.fileURLWithPath_(osfilename) qtmovie, error = QTMovie.movieWi...
print 'TYPE', type(path) print path.urlize()
def get_movie_from_file(self, path): osfilename = utils.filename_type_to_os_filename(path) print 'TRYING TO OPEN %s' % osfilename try: print 'TYPE', type(path) print path.urlize() url = NSURL.URLWithString_(path.urlize()) print 'URL', url except: url = NSURL.fileURLWithPath_(osfilename) qtmovie, error = QTMovie.movieWi...
print 'URL', url
def get_movie_from_file(self, path): osfilename = utils.filename_type_to_os_filename(path) print 'TRYING TO OPEN %s' % osfilename try: print 'TYPE', type(path) print path.urlize() url = NSURL.URLWithString_(path.urlize()) print 'URL', url except: url = NSURL.fileURLWithPath_(osfilename) qtmovie, error = QTMovie.movieWi...
print 'DIDNT WORK 1'
def get_movie_from_file(self, path): osfilename = utils.filename_type_to_os_filename(path) print 'TRYING TO OPEN %s' % osfilename try: print 'TYPE', type(path) print path.urlize() url = NSURL.URLWithString_(path.urlize()) print 'URL', url except: url = NSURL.fileURLWithPath_(osfilename) qtmovie, error = QTMovie.movieWi...
print 'DIDNT WORK 2'
def get_movie_from_file(self, path): osfilename = utils.filename_type_to_os_filename(path) print 'TRYING TO OPEN %s' % osfilename try: print 'TYPE', type(path) print path.urlize() url = NSURL.URLWithString_(path.urlize()) print 'URL', url except: url = NSURL.fileURLWithPath_(osfilename) qtmovie, error = QTMovie.movieWi...
"feed.origURL IS NULL AND "
def watchable_video_view(cls): return cls.make_view( "not isContainerItem AND " "(deleted IS NULL or not deleted) AND " "(is_file_item OR rd.main_item_id=item.id) AND " "feed.origURL IS NULL AND " "item.file_type='video'", joins={'feed': 'item.feed_id=feed.id', 'remote_downloader as rd': 'item.downloader_id=rd.id'})
"feed.origURL IS NULL AND "
def watchable_audio_view(cls): return cls.make_view( "not isContainerItem AND " "(deleted IS NULL or not deleted) AND " "(is_file_item OR rd.main_item_id=item.id) AND " "feed.origURL IS NULL AND " "item.file_type='audio'", joins={'feed': 'item.feed_id=feed.id', 'remote_downloader as rd': 'item.downloader_id=rd.id'})
"(deleted IS NULL OR nrot deleted) AND "
"(deleted IS NULL OR not deleted) AND "
def watchable_other_view(cls): return cls.make_view( "(deleted IS NULL OR nrot deleted) AND " "(is_file_item OR rd.id IS NOT NULL) AND " "parent_id IS NOT NULL AND " "item.file_type='other'", joins={'feed': 'item.feed_id=feed.id', 'remote_downloader as rd': 'rd.main_item_id=item.id'})
"parent_id IS NOT NULL AND "
def watchable_other_view(cls): return cls.make_view( "(deleted IS NULL OR nrot deleted) AND " "(is_file_item OR rd.id IS NOT NULL) AND " "parent_id IS NOT NULL AND " "item.file_type='other'", joins={'feed': 'item.feed_id=feed.id', 'remote_downloader as rd': 'rd.main_item_id=item.id'})
self.player.stop() self.player = None if self.video_display is not None: self.remove_video_display() self.video_display = None
self.stop(save_resume_time=False)
def _select_current(self): item_info = self.playlist[self.position] if not app.config.get(prefs.PLAY_IN_MIRO): if self.is_playing: self.player.stop() self.player = None if self.video_display is not None: self.remove_video_display() self.video_display = None # FIXME - do this to avoid "currently playing green thing. # s...
self.program_info = None
self._program_info = None
def __init__(self, item): self.item = item self.video_path = item.get_filename() if self.video_path is None: self.program_info = None return # add a random string to the filename to ensure it's unique. Two # videos can have the same basename if they're in different # directories. thumbnail_filename = '%s.%s.png' % (os...
self.program_info = None
def __init__(self, item): self.item = item self.video_path = item.get_filename() if self.video_path is None: self.program_info = None return # add a random string to the filename to ensure it's unique. Two # videos can have the same basename if they're in different # directories. thumbnail_filename = '%s.%s.png' % (os...
return
self._program_info = None def _get_program_info(self): try: return self._program_info except AttributeError: self._calc_program_info() return self._program_info def _calc_program_info(self):
def __init__(self, item): self.item = item self.video_path = item.get_filename() if self.video_path is None: self.program_info = None return # add a random string to the filename to ensure it's unique. Two # videos can have the same basename if they're in different # directories. thumbnail_filename = '%s.%s.png' % (os...
self.thread_started = False
def __init__ (self): self.in_shutdown = False self.queue = Queue.Queue() self.thread = None self.thread_started = False
self.thread_started = True
def start_thread(self): self.thread = threading.Thread(name='Movie Data Thread', target=self.thread_loop) self.thread.setDaemon(True) self.thread.start() self.thread_started = True
if not self.thread_started: logging.info("Movie data thread not started, waiting to " "request update for %s", item) addTimeout(1, self.request_update, "movie data update request", args=(item,)) return
def request_update(self, item): if self.in_shutdown: return if not self.thread_started: logging.info("Movie data thread not started, waiting to " "request update for %s", item) addTimeout(1, self.request_update, "movie data update request", args=(item,)) return
if not self.media_type_checked: self.file_type = self._file_type_for_filename(filename)
def set_filename(self, filename): self.filename = filename # self.file_type = self._file_type_for_filename(filename)
Menu(_("Convert to..."), "ConvertMenu", _get_convert_menu()), Separator(),
def get_menu(): """Returns the default menu structure. Call this, then make whatever platform-specific changes you need to make. """ mbar = Menu("", "TopLevel", [ Menu(_("_File"), "FileMenu", [ MenuItem(_("_Open"), "Open", Shortcut("o", MOD), groups=["NonPlaying"]), MenuItem(_("_Download Item"), "NewDownload", groups=...
return list(self.iter_items, start_id)
return list(self.iter_items(start_id))
def get_items(self, start_id=None): """Get a list of ItemInfo objects in this list""" return list(self.iter_items, start_id)
return 'unplayable'
return 'other'
def get_type(qtmovie): if qtmovie is None: return 'unplayable' allTracks = qtmovie.tracks() if len(allTracks) == 0: return 'unplayable' has_audio = False has_video = False for track in allTracks: media_type = track.attributeForKey_(QTKit.QTTrackMediaTypeAttribute) if media_type in mediatypes.AUDIO_MEDIA_TYPES: has_au...
item_type = 'unplayable'
item_type = 'other'
def get_type(qtmovie): if qtmovie is None: return 'unplayable' allTracks = qtmovie.tracks() if len(allTracks) == 0: return 'unplayable' has_audio = False has_video = False for track in allTracks: media_type = track.attributeForKey_(QTKit.QTTrackMediaTypeAttribute) if media_type in mediatypes.AUDIO_MEDIA_TYPES: has_au...
while True: load_state = qtmovie.attributeForKey_(QTKit.QTMovieLoadStateAttribute) if load_state == 100000: break time.sleep(0.1)
movie_type = get_type(qtmovie) print "Miro-Movie-Data-Type: %s" % movie_type
def extractThumbnail(qtmovie, target, width=0, height=0): try: qttime = qtmovie.duration() qttime = utils.qttimevalue_set(qttime, int(utils.qttimevalue(qttime) * 0.5)) frame = qtmovie.frameImageAtTime_(qttime) if frame is objc.nil: return "Failure" frameSize = frame.size() if frameSize.width == 0 or frameSize.height =...
thmbResult = extractThumbnail(qtmovie, thumbPath) print "Miro-Movie-Data-Thumbnail: %s" % thmbResult
if movie_type == "video": max_load_state = 100000 if utils.getMajorOSVersion() == 8: max_load_state = 20000 while True: load_state = qtmovie.attributeForKey_(QTKit.QTMovieLoadStateAttribute) if load_state >= max_load_state or load_state == -1: break time.sleep(0.1)
def extractThumbnail(qtmovie, target, width=0, height=0): try: qttime = qtmovie.duration() qttime = utils.qttimevalue_set(qttime, int(utils.qttimevalue(qttime) * 0.5)) frame = qtmovie.frameImageAtTime_(qttime) if frame is objc.nil: return "Failure" frameSize = frame.size() if frameSize.width == 0 or frameSize.height =...
movie_type = get_type(qtmovie) print "Miro-Movie-Data-Type: %s" % movie_type
thmbResult = extractThumbnail(qtmovie, thumbPath) print "Miro-Movie-Data-Thumbnail: %s" % thmbResult else: print "Miro-Movie-Data-Thumbnail: Failure"
def extractThumbnail(qtmovie, target, width=0, height=0): try: qttime = qtmovie.duration() qttime = utils.qttimevalue_set(qttime, int(utils.qttimevalue(qttime) * 0.5)) frame = qtmovie.frameImageAtTime_(qttime) if frame is objc.nil: return "Failure" frameSize = frame.size() if frameSize.width == 0 or frameSize.height =...
self.httpserver.pause_after(-1)
def status_callback(): if self.downloader2.state == 'finished': self.stopEventLoop(False)
prev, new, pending = message.parse_state_changed() if new == gst.STATE_PAUSED:
prev, new_, pending = message.parse_state_changed() if new_ == gst.STATE_PAUSED:
def on_bus_message(self, bus, message): if message.src == self.pipeline: if message.type == gst.MESSAGE_STATE_CHANGED: prev, new, pending = message.parse_state_changed() if new == gst.STATE_PAUSED: gobject.idle_add(self.paused_reached)
prev, new, pending = message.parse_state_changed() if new == gst.STATE_PAUSED:
prev, new_, pending = message.parse_state_changed() if new_ == gst.STATE_PAUSED: for sink in self.thumbnail_pipeline.sinks(): name = sink.get_name() factoryname = sink.get_factory().get_name() if factoryname == "fakesink": pad = sink.get_pad("sink") self.buffer_probes[name] = pad.add_buffer_probe( self.buffer_probe_han...
def on_bus_message(self, bus, message): if message.src == self.pipeline: if message.type == gst.MESSAGE_STATE_CHANGED: prev, new, pending = message.parse_state_changed() if new == gst.STATE_PAUSED: gobject.idle_add(self.paused_reached)
gst.SEEK_TYPE_SET, self.duration / 2,
gst.SEEK_TYPE_SET, min(self.duration / 2, 20 * gst.SECOND),
def on_bus_message(self, bus, message): if message.src == self.pipeline: if message.type == gst.MESSAGE_STATE_CHANGED: prev, new, pending = message.parse_state_changed() if new == gst.STATE_PAUSED: gobject.idle_add(self.paused_reached)
if self.saw_video_tag == False and self.saw_audio_tag == True:
if not self.saw_video_tag and self.saw_audio_tag:
def paused_reached(self): self.saw_video_tag = False self.saw_audio_tag = False
if self.saw_video_tag == False and self.saw_audio_tag == False:
if not self.saw_video_tag and not self.saw_audio_tag:
def paused_reached(self): self.saw_video_tag = False self.saw_audio_tag = False
for sink in self.thumbnail_pipeline.sinks(): name = sink.get_name() factoryname = sink.get_factory().get_name() if factoryname == "fakesink": pad = sink.get_pad("sink") self.buffer_probes[name] = pad.add_buffer_probe( self.buffer_probe_handler, name)
def paused_reached(self): self.saw_video_tag = False self.saw_audio_tag = False
if len(argv) < 3: print "Syntax: gst_extractor.py <filename> <thumbnail>" sys.exit(1)
def main(argv): if len(argv) < 3: print "Syntax: gst_extractor.py <filename> <thumbnail>" sys.exit(1) if "--verbose" in argv: make_verbose() argv.remove("--verbose") extractor = Extractor(argv[1], argv[2], handle_result) gtk.gdk.threads_init() gtk.main()
self.assertEqual(cleaned.__class__, str)
self.assertEqual(cleaned.__class__, FilenameType)
def testIt(filename): cleaned = clean_filename(filename) self.assertEqual(cleaned.__class__, str) self.assertNotEqual(cleaned, '') path = os.path.join(tempdir, cleaned) f = open(path, 'w') f.write("AOEUOAEU") f.close() os.remove(path)