miro core
This covers messages, message handlers, event loops, configuration,
updating, downloaders, ...
appconfig - application configuration
miro.appconfig – Contains the AppConfig class, which handles
holding the values of app.config.
If Miro is using a theme, then the theme’s app.config value overrides
the default one.
Most uses of AppConfig will come from the global variable
app.configfile. This is setup in config.load().
config - configuration classes and functions
miro.config – Configuration and preference related functions.
-
miro.config.add_change_callback(callback)
Attaches change notification callback functions.
Callback functions should have a signature like
callback_function: key * value -> None. Example:
def callback_function(key, value):
if key == prefs.PRESERVE_X_GB_FREE:
blah blah blah
-
miro.config.load(theme=None)
- The theme parameter is a horrible hack to load the theme before we
can import other modules. pybridge makes the extra, early call
-
miro.config.remove_change_callback(callback)
- Removes change notification callback functions.
prefs - preferences
miro.prefs – Defines Pref and lists global preferences.
-
class miro.prefs.Pref(key, default, platformSpecific, possible_values=None, failsafe_value=None)
Class for defining preferences. Preferences are defined using
keywords:
- key – the name of the key–must be unique among all preferences
- default – the default value to use
- platformSpecific – whether or not this is platform specific;
this should usually be False
- possible_values – a list of possible values for this preference;
if the saved value gets corrupted for some reason and therefore does not
correspond to any of the possible values, the failsafe is picked instead.
- failsafe_value – value to be used in case of corruption (see above).
Pref example:
FOO = Pref(key="foo", default=None, platformSpecific=False)
messagehandler - message handler classes and backend message handler
miro.messagehandler` – Backend message handler
-
class miro.messagehandler.CountTracker
- Tracks downloads count or new videos count
-
class miro.messagehandler.ViewTracker
- Handles tracking views for TrackGuides, TrackChannels, TrackPlaylist and TrackItems.
messages - backend and frontend messages
miro.messages – Message passing between the frontend thread
and the backend thread.
The backend thread is the eventloop, which processes things like feed
updates and handles reading and writing to the database. The frontend
thread is the thread of the UI toolkit we’re using. Communication
between the two threads is handled by passing messages between the
two. These messages are handled asynchronously.
This module defines the messages that are passed between the two
threads.
-
class miro.messages.AddFiles(filenames)
- This is like OpenIndividualFiles, but is handled differently in
that adding files doesn’t cause videos that were added to be
played.
-
class miro.messages.AddVideosToPlaylist(playlist_id, video_ids)
- Adds a list of videos to a playlist.
-
class miro.messages.AutodownloadChange(id, setting)
- Inform the backend that the user changed the auto-download
setting for a feed. The possible setting values are all,
new and off.
-
class miro.messages.BackendMessage
- Base class for Messages that get sent to the backend.
-
class miro.messages.CancelAllDownloads
- Cancels all downloading items.
-
class miro.messages.CancelDownload(id)
- Cancel downloading an item.
-
class miro.messages.ChangeMoviesDirectory(path, migrate)
Change the current movies directory.
If migrate is True, then the backend will send a series of
MigrationProgress messages while the migration happens.
-
class miro.messages.ChannelInfo(channel_obj)
Tracks the state of a channel
| Parameters: |
- name – channel name
- url – channel url (None for channel folders)
- id – object id
- section – which section this is in (audio or video)
- tab_icon – path to this channel’s tab icon
- thumbnail – path to this channel’s thumbnail
- num_downloaded – number of downloaded items in the feed
- unwatched – number of unwatched videos
- available – number of newly downloaded videos
- is_folder – is this a channel folder?
- is_directory_feed – is this channel is a watched directory?
- parent_id – id of parent folder or None
- is_updating – whether or not the feed is currently updating
- has_downloading – are videos currently being downloaded for
this channel?
- base_href – url to use for relative links for items in this
channel. This will be None for ChannelFolders.
- autodownload_mode – current autodownload mode (all,
new or off)
- search_term – the search term used for this feed or None
- expire – expire type (system, never, or feed)
- expire_time – expire time in hours
- max_new – maximum number of items this feed wants
- max_old_items – maximum number of old items to remember
|
-
class miro.messages.CheckVersion(up_to_date_callback)
- Checks whether Miro is the most recent version.
-
class miro.messages.CleanFeed(channel_id)
- Tells the backend to clean the old items from a feed.
-
class miro.messages.CurrentFrontendState(list_view_displays, sort_states)
- Returns the latest data saved with SaveFrontendState.
-
class miro.messages.CurrentSearchInfo(engine, text)
- Informs the frontend of the current search settings.
-
class miro.messages.DeleteFeed(id, is_folder, keep_items)
- Delete a feed.
-
class miro.messages.DeletePlaylist(id, is_folder)
- Delete a playlist.
-
class miro.messages.DeleteSite(id)
- Delete an external channel guide.
-
class miro.messages.DeleteVideo(id)
- Delete the video for an item’s video.
-
class miro.messages.DeleteWatchedFolder(id)
Delete a watched folder.
Note
This separate from DeleteFeed since not all watched folders are
visible.
-
class miro.messages.DownloadCountChanged(count)
- Informs the frontend that number of downloads has changed.
-
class miro.messages.DownloadInfo(downloader)
Tracks the download state of an item.
| Parameters: |
- downloaded_size – bytes downloaded
- rate – current download rate, in bytes per second
- state – one of downloading, uploading, finished,
failed or paused. uploading is for
torrents only. It means that we’ve finished
downloading the torrent and are now seeding it.
- eta – Estimated seconds before the download is finished
- startup_activity – The current stage of starting up
- finished – True if the item has finished downloading
- torrent – Is this a Torrent download?
|
-
class miro.messages.DownloadURL(url, handle_unknown_callback=None, metadata=None)
Downloads the item at a url.
| Parameters: |
- url – the url of the thing to download
- metadata – dict of name/value pairs to include in the item.
|
| Handle_unknown_callback: |
| | if the thing at the url isn’t something that
Miro knows what to do with, then it calls
this callback. The handler should take a
single argument which is the url that
couldn’t be handled.
|
-
class miro.messages.ExportSubscriptions(filename)
Tell the backend to export subscriptions to an .opml file.
| Parameter: | filename – file name to export to |
-
class miro.messages.FeedlessDownloadStarted
- Inform the frontend that a new video started downloading because a
subscribe link was clicked.
-
class miro.messages.FolderExpandedChange(type, id, expanded)
- Inform the backend when a folder gets expanded/collapsed.
-
class miro.messages.FrontendMessage
- Base class for Messages that get sent to the frontend.
-
class miro.messages.FrontendStarted
- Inform the backend that the frontend has finished starting up.
-
class miro.messages.GuideInfo(guide)
Tracks the state of a channel guide
| Parameters: |
- name – channel name
- id – object id
- url – URL for the guide
- allowed_urls – URLs that should be also considered part of the guide
- default – is this the default channel guide?
- favicon – the favicon for the guide
- faviconIsDefault – true if the guide is using the default site
icon and not a favicon from the web
|
-
class miro.messages.GuideList(guides)
Sends the frontend the initial list of channel guides
| Parameters: |
- default_guide – The Default channel guide
- guides – list added channel guides
|
-
class miro.messages.ImportFeeds(filename)
Tell the backend to import feeds from an .opml file.
| Parameter: | filename – file name that exists |
-
class miro.messages.ItemInfo(item)
Tracks the state of an item
| Parameters: |
- name – name of the item
- id – object id
- feed_id – id for the items feed
- feed_name – name of the feed item is attached to
- feed_url – URL of the feed item is attached to
- description – longer description for the item (HTML)
- state – see Item.get_state()
- release_date – datetime object when the item was published
- size – size of the item in bytes
- duration – length of the video in seconds
- resume_time – time at which playback should restart
- permalink – URL to a permalink to the item (or None)
- commentslink – URL to a comments page for the item (or None)
- payment_link – URL of the payment page associated with the item
(or empty string)
- has_sharable_url – does this item have a sharable URL?
- can_be_saved – is this an expiring downloaded item?
- downloaded – has the item been downloaded?
- is_external – is this item external (true) or from a channel
(false)?
- expiration_date – datetime object for when the item will expire
(or None)
- item_viewed – has the user ever seen the item?
- video_watched – has the user watched the video for the item?
- video_path – the file path to the video for this item (or None)
- file_type – type of the downloaded file (video/audio/other)
- seeding_status – Torrent seeding status (‘seeding’, ‘stopped’,
or None)
- thumbnail – path to the thumbnail for this file
- thumbnail_url – URL for the item’s thumbnail (or None)
- file_format – User-facing format description. Possibly the
file type, pulled from the mime_type, or more
generic, like “audio”
- license – this file’s license, if known.
- mime_type – mime-type of the enclosure that would be downloaded
- file_url – URL of the enclosure that would be downloaded
- download_info – DownloadInfo object containing info about the
download (or None)
- is_container_item – whether or not this item is actually a
collection of files as opposed to an
individual item
- children – for container items the children of the item.
- is_playable – is this item a audio/video file, or a container that
contains audio/video files inside.
- leechers – (Torrent only) number of leeching clients
- seeders – (Torrent only) number of seeding clients
- up_rate – (Torrent only) how fast we’re uploading data
- down_rate – (Torrent only) how fast we’re downloading data
- up_total – (Torrent only) total amount we’ve uploaded
- down_total – (Torrent only) total amount we’ve downloaded
|
-
class miro.messages.ItemList(type, id, item_infos)
Sends the frontend the initial list of items for a feed
| Parameters: |
- type – type of object being tracked (same as in TrackItems)
- id – id of the object being tracked (same as in TrackItems)
- items – list of ItemInfo objects
|
-
class miro.messages.ItemsChanged(type, id, added, changed, removed)
Informs the frontend that the items in a feed have changed.
| Parameters: |
- type – type of object being tracked (same as in TrackItems)
- id – id of the object being tracked (same as in TrackItems)
- added – list containing an ItemInfo object for each added item.
The order will be the order they were added.
- changed – set containing an ItemInfo for each changed item.
- removed – set containing ids for each item that was removed
|
-
class miro.messages.KeepVideo(id)
- Cancel the auto-expiration of an item’s video.
-
class miro.messages.MarkFeedSeen(id)
- Mark a feed as seen.
-
class miro.messages.MarkItemUnwatched(id)
- Mark an item as unwatched.
-
class miro.messages.MarkItemWatched(id)
- Mark an item as watched.
-
class miro.messages.Message
Base class for all Messages.
-
classmethod install_handler(handler)
- Install a new message handler for this class. When
send_to_frontend() or send_to_backend() is called, this handler will
be invoked.
-
class miro.messages.MessageToUser(title, desc)
- Lets the backend send messages directly to the user.
-
class miro.messages.MigrationProgress(iteration, total_files, finished)
- Inform the frontend of progress while we migrate files.
-
class miro.messages.NewAudioCountChanged(count)
- Informs the frontend that number of new videos has changed.
-
class miro.messages.NewFeed(url, section=u'video')
- Creates a new feed.
-
class miro.messages.NewFeedFolder(name, section, child_feed_ids)
- Create a new feed folder.
-
class miro.messages.NewFeedSearchEngine(search_engine_info, search_term, section=u'video')
- Creates a new feed from a search engine.
-
class miro.messages.NewFeedSearchFeed(channel_info, search_term, section=u'video')
- Creates a new feed based on a search through a feed.
-
class miro.messages.NewFeedSearchURL(url, search_term, section)
- Creates a new feed from a url.
-
class miro.messages.NewGuide(url)
- Create a new channel guide.
-
class miro.messages.NewPlaylist(name, ids)
- Create a new playlist.
-
class miro.messages.NewPlaylistFolder(name, child_playlist_ids)
- Create a new playlist folder.
-
class miro.messages.NewVideoCountChanged(count)
- Informs the frontend that number of new videos has changed.
-
class miro.messages.NewWatchedFolder(path)
- Creates a new watched folder.
-
class miro.messages.NotifyUser(title, body, notify_type=None)
Sends a notification to the user.
Can optionally give a notification type, so we can filter based on
whether the user has selected that they are interested in
receiving notifications of this type.
-
class miro.messages.OpenInExternalBrowser(url)
- Opens the specified url in an external browser.
-
class miro.messages.OpenIndividualFile(filename)
- Open a single file item in Miro.
-
class miro.messages.OpenIndividualFiles(filenames)
- Open a list of file items in Miro.
-
class miro.messages.PauseAllDownloads
- Pauses all downloading items.
-
class miro.messages.PauseDownload(id)
- Pause downloading an item.
-
class miro.messages.PausedCountChanged(count)
- Informs the frontend that number of paused downloading items
has changed.
-
class miro.messages.PendingDownloadInfo
- DownloadInfo object for pending downloads (downloads queued,
but not started because we’ve reached some limit)
-
class miro.messages.PlayAllUnwatched
- Figures out all the unwatched items and plays them.
-
class miro.messages.PlayMovie(item_infos)
- Starts playing a specific movie.
-
class miro.messages.PlaylistInfo(playlist_obj)
Tracks the state of a playlist
| Parameters: |
- name – playlist name
- id – object id
- is_folder – is this a playlist folder?
|
-
class miro.messages.PlaylistReordered(id, item_ids)
Inform the backend when the items in a playlist are re-ordered.
| Parameters: |
- id – playlist that was re-ordered.
- item_ids – List of ids for item in the playlist, in their new
order.
|
-
class miro.messages.QueryFrontendState
- Ask for a CurrentFrontendState message to be sent back.
-
class miro.messages.QuerySearchInfo
- Ask the backend to send a CurrentSearchInfo message.
-
class miro.messages.RemoveVideoEntry(id)
- Remove the entry for an external video.
-
class miro.messages.RemoveVideosFromPlaylist(playlist_id, video_ids)
- Removes a list of videos from a playlist.
-
class miro.messages.RenameObject(type, id, new_name)
Tell the backend to rename a feed/playlist/folder.
| Parameters: |
- type – feed, playlist, feed-folder or
playlist-folder
- id – id of the object to rename
- new_name – new name for the object
|
-
class miro.messages.RenameVideo(id, new_name)
- Renames the video.
-
class miro.messages.ReportCrash(report, text, send_report)
- Sends a crash report.
-
class miro.messages.ResumeAllDownloads
- Resumes all downloading items.
-
class miro.messages.ResumeDownload(id)
- Resume downloading an item.
-
class miro.messages.RevertFeedTitle(id)
- Reverts the feed’s title back to the original.
-
class miro.messages.RevertItemTitle(id)
- Reverts the item’s title back to the original.
-
class miro.messages.SaveFrontendState(list_view_displays, sort_states)
- Save data for the frontend.
-
class miro.messages.SaveItemAs(id, filename)
- Saves an item in the dark clutches of Miro to somewhere else.
-
class miro.messages.Search(searchengine_id, terms)
Search a search engine with a search term.
The backend will send a SearchComplete message.
-
class miro.messages.SearchComplete(engine, query, result_count)
- Notifies the backend that the search was complete.
-
class miro.messages.SetFeedExpire(channel_info, expire_type, expire_time)
- Sets the expiration for a feed.
-
class miro.messages.SetFeedMaxNew(channel_info, max_new)
- Sets the feed’s max new property.
-
class miro.messages.SetFeedMaxOldItems(channel_info, max_old_items)
- Sets the feed’s max old items property.
-
class miro.messages.SetItemResumeTime(id, time)
- Set an item resume time.
-
class miro.messages.SetWatchedFolderVisible(id, visible)
- Changes if a watched folder is visible in the tab list or not.
-
class miro.messages.StartDownload(id)
- Start downloading an item.
-
class miro.messages.StartUpload(id)
- Start uploading a torrent.
-
class miro.messages.StartupFailure(summary, description)
The startup process failed. The frontend should inform the
user that this happened and quit.
Attributes:
:param summary: Short, user-friendly, summary of the problem.
:param description: Longer explanation of the problem.
-
class miro.messages.StartupSuccess
- The startup process is complete. The frontend should wait for
this signal to show the UI to the user.
-
class miro.messages.StopTrackingChannels
- Stop tracking channels.
-
class miro.messages.StopTrackingDownloadCount
- Stop tracking the download count.
-
class miro.messages.StopTrackingGuides
- Stop tracking guides.
-
class miro.messages.StopTrackingItems(type, id)
- Stop tracking items for a feed.
-
class miro.messages.StopTrackingNewAudioCount
- Stop tracking the new audio items count.
-
class miro.messages.StopTrackingNewVideoCount
- Stop tracking the new videos count.
-
class miro.messages.StopTrackingPausedCount
- Stop tracking the paused count.
-
class miro.messages.StopTrackingPlaylists
- Stop tracking playlists.
-
class miro.messages.StopTrackingUnwatchedCount
- Stop tracking the unwatched items count.
-
class miro.messages.StopTrackingWatchedFolders
- Stop tracking watched folders.
-
class miro.messages.StopUpload(id)
- Stop uploading a torrent.
-
class miro.messages.SubscriptionLinkClicked(url)
- Inform the backend that the user clicked on a subscription link
in a web browser.
-
class miro.messages.TabList(type)
Sends the frontend the current list of channels and playlists
This is sent at startup and when the changes to the list of
channels/playlists is too complex to describe with a TabsChanged message.
| Parameters: |
- type – feed or playlist
- toplevels – the list of ChannelInfo/PlaylistInfo objects
without parents
- folder_children – dict mapping channel folder ids to a list of
ChannelInfo/PlaylistInfo objects for their
children
- expanded_folders – set containing ids of the folders that should
be initially expanded.
|
-
class miro.messages.TabsChanged(type, added, changed, removed, section=None)
Informs the frontend that the channel list or playlist list has been
changed.
| Parameters: |
- type – feed, playlist or guide
- added – ChannelInfo/PlaylistInfo object for each added tab. The
list will be in the same order that the tabs were added.
- changed – list of ChannelInfo/PlaylistInfos for each changed tab.
- removed – list of ids for each tab that was removed
- section – audio, video, or None (used for channels and
channel folders)
|
-
class miro.messages.TabsReordered
Inform the backend when the channel tabs are rearranged. This
includes simple position changes and also changes to which folders
the channels are in.
| Parameters: |
- toplevels – a dict of {‘type’: [channelinfo1,
channelinfo2]}, where channelinfo is a
ChannelInfo object without parents
- folder_children – dict mapping channel folder ids to a list of
ChannelInfo objects for their children
|
-
class miro.messages.TrackChannels
Begin tracking channels.
After this message is sent, the backend will send back a ChannelList
message, then it will send ChannelsChanged messages whenever the channel
list changes.
-
class miro.messages.TrackDownloadCount
- Start tracking the number of downloading items. After this message is
received the backend will send a corresponding DownloadCountChanged
message. It will also send DownloadCountChanged whenever the count
changes.
-
class miro.messages.TrackGuides
Begin tracking guides.
After this message is sent, the backend will send back a GuideList
message, then it will send GuidesChanged messages whenever the guide
list changes.
-
class miro.messages.TrackItems(type, id)
Begin tracking items for a feed
After this message is sent, the backend will send back a ItemList message,
then it will send ItemsChanged messages for items in the feed.
type is the type of object that we are tracking items for. It can be one
of the following:
- feed – Items in a feed
- playlist – Items in a playlist
- new – Items that haven’t been watched
- downloading – Items being downloaded
- library – All items
id should be the id of a feed/playlist. For new, downloading and library
it is ignored.
-
class miro.messages.TrackItemsManually(id, ids_to_track)
Track a manually specified list of items.
ItemList and ItemsChanged messages will have “manual” as the type and
will use the id specified in the constructed.
-
class miro.messages.TrackNewAudioCount
- Start tracking the number of new audio items. When this
message is received the backend will send a corresponding
NewAudioCountChanged message. It will also send
NewAudioCountChanged whenever the count changes.
-
class miro.messages.TrackNewVideoCount
- Start tracking the number of new videos. When this message is
received the backend will send a corresponding
NewVideoCountChanged message. It will also send
NewVideoCountChanged whenever the count changes.
-
class miro.messages.TrackPausedCount
- Start tracking the number of paused downloading items. After
this message is received, the backend will send a corresponding
PausedCountChanged message. It will also send PausedCountChanged
whenever the count changes.
-
class miro.messages.TrackPlaylists
Begin tracking playlists.
After this message is sent, the backend will send back a PlaylistList
message, then it will send PlaylistsChanged messages whenever the list of
playlists changes.
-
class miro.messages.TrackUnwatchedCount
- Start tracking the number of unwatched items. When this
message is received, the backend will send a corresponding
UnwatchedCountChanged message. It will also send
UnwatchedCountChanged whenever the count changes.
-
class miro.messages.TrackWatchedFolders
Begin tracking watched folders
After this message is sent, the backend will send back a
WatchedFolderList message, then it will send WatchedFoldersChanged
messages whenever the list changes.
-
class miro.messages.UnwatchedCountChanged(count)
- Informs the frontend that number of unwatched items has changed.
-
class miro.messages.UpdateAllFeeds
- Updates all feeds.
-
class miro.messages.UpdateFeed(id)
- Updates a feed.
-
class miro.messages.UpdateFeedFolder(id)
- Updates the feeds in a feed folder.
-
class miro.messages.WatchedFolderInfo(channel)
Tracks the state of a watched folder.
| Parameters: |
- id – ID of the channel
- path – Path to the folder being watched
- visible – Is the watched folder shown on the tab list?
|
-
class miro.messages.WatchedFolderList(watched_folders)
Sends the frontend the initial list of watched folders.
| Parameter: | watched_folders – List of watched folders |
-
class miro.messages.WatchedFoldersChanged(added, changed, removed)
Informs the frontend that the watched folder list has changed.
| Parameters: |
- added – WatchedFolderInfo object for each added watched folder.
The list will be in the same order that they were added.
- changed – The list of WatchedFolderInfo for each changed watched
folder.
- removed – list of ids for each watched folder that was removed.
|
eventloop - event loop
miro.eventloop – Event loop handler.
This module handles the democracy event loop which is responsible for
network requests and scheduling.
TODO: handle user setting clock back