Esempio n. 1
0
def _amz_callback(data):
    content = decrypt_amz(base64.b64decode(data['body'])).rstrip('\x00\x08')

    dom = minidom.parseString(content)

    from miro.singleclick import _build_entry, download_video

    for track in dom.documentElement.getElementsByTagName('track'):
        url = None
        additional = {}
        for node in track.childNodes:
            if node.nodeType != node.TEXT_NODE:
                key = node.nodeName
                value = node.childNodes[0].nodeValue
                if key == 'location':
                    url = value
                elif key == 'title':
                    additional['title'] = value
                elif key == 'image':
                    additional['thumbnail'] = value
                elif key == 'duration':
                    additional['length'] = int(value) / 1000
        if url is None:
            app.controller.failed_soft("_amz_callback",
                                       "could not find URL for track",
                                       with_exception=False)
        else:
            entry = _build_entry(url, 'audio/mp3', additional)
            download_video(entry)
Esempio n. 2
0
def _download_emx_files(file_):
    dom = minidom.parse(file_)

    from miro.singleclick import _build_entry, download_video

    for track in dom.documentElement.getElementsByTagName('TRACK'):
        url = None
        additional = {}
        for node in track.childNodes:
            if node.nodeType != node.TEXT_NODE:
                key = node.nodeName
                if node.childNodes:
                    value = node.childNodes[0].nodeValue
                else:
                    value = None
                if key == 'TRACKURL':
                    url = value
                elif key == 'TITLE':
                    additional['title'] = value
                elif key == 'ALBUMARTLARGE':
                    additional['thumbnail'] = value
                elif key == 'ALBUMART' and 'thumbnail' not in additional:
                    additional['thumbnail'] = value
                elif key == 'DURATION':
                    additional['length'] = int(value)
        if url is None:
            app.controller.failed_soft("_emx_callback",
                                       "could not find URL for track",
                                       with_exception=False)
        else:
            entry = _build_entry(url, 'audio/mp3', additional)
            download_video(entry)
Esempio n. 3
0
def _m3u_callback(data):
    from miro.singleclick import _build_entry, download_video

    for line in data['body'].split('\n'):
        line = line.strip()
        if line.startswith('#'): # comment
            continue
        elif line:
            entry = _build_entry(line.decode('utf8'), 'audio/mp3')
            download_video(entry)
Esempio n. 4
0
def _amz_callback(data):
    if data.lstrip().startswith('<playlist>'):  # plain XML
        content = data.strip()
    else:
        try:
            content = decrypt_amz(base64.b64decode(data)).rstrip('\x00\x08')
        except Exception:
            app.controller.failed_soft('_amz_callback',
                                       'could not b64decde/decrypt:\n%r' %
                                       data,
                                       with_exception=True)
            return

    try:
        dom = minidom.parseString(content)
    except Exception:
        app.controller.failed_soft('_amz_callback',
                                   'could not parse data:\n%r' % content,
                                   with_exception=True)
        return

    from miro.singleclick import _build_entry, download_video

    for track in dom.documentElement.getElementsByTagName('track'):
        url = None
        additional = {}
        for node in track.childNodes:
            if node.nodeType != node.TEXT_NODE:
                key = node.nodeName
                value = node.childNodes[0].nodeValue
                if key == 'location':
                    url = value
                elif key == 'title':
                    additional['title'] = value
                elif key == 'image':
                    additional['thumbnail'] = value
                elif key == 'duration':
                    additional['length'] = int(value) / 1000
        if url is None:
            app.controller.failed_soft("_amz_callback",
                                       "could not find URL for track",
                                       with_exception=False)
        else:
            entry = _build_entry(url, 'audio/mp3', additional)
            download_video(entry)
Esempio n. 5
0
def _amz_callback(data):
    if data.lstrip().startswith('<playlist>'): # plain XML
        content = data.strip()
    else:
        try:
            content = decrypt_amz(base64.b64decode(data)).rstrip('\x00\x08')
        except Exception:
            app.controller.failed_soft(
                '_amz_callback',
                'could not b64decde/decrypt:\n%r' % data,
                with_exception=True)
            return

    try:
        dom = minidom.parseString(content)
    except Exception:
        app.controller.failed_soft('_amz_callback',
                                   'could not parse data:\n%r' % content,
                                   with_exception=True)
        return

    from miro.singleclick import _build_entry, download_video

    for track in dom.documentElement.getElementsByTagName('track'):
        url = None
        additional = {}
        for node in track.childNodes:
            if node.nodeType != node.TEXT_NODE:
                key = node.nodeName
                value = node.childNodes[0].nodeValue
                if key == 'location':
                    url = value
                elif key == 'title':
                    additional['title'] = value
                elif key == 'image':
                    additional['thumbnail'] = value
                elif key == 'duration':
                    additional['length'] = int(value) / 1000
        if url is None:
            app.controller.failed_soft("_amz_callback",
                                       "could not find URL for track",
                                       with_exception=False)
        else:
            entry = _build_entry(url, 'audio/mp3', additional)
            download_video(entry)
Esempio n. 6
0
    def handle_download(self, download_dict, parent_folder):
        """
        Download subscriptions look like::

            {
            'type': 'download',
            'url': URL of the file to download
            'title': name of the download (optional),
            'link': page representing this download (optional),
            'feed': RSS feed containing this item (optional),
            'mime_type': the MIME type of the item (optional),
            'description': a description of the item (optional),
            'thumbnail': a thumbnail image for the item (optional),
            'length': the length in seconds of the item (optional)
            }
        """
        assert parent_folder is None, "no folders in downloads"
        url = download_dict["url"]
        mime_type = download_dict.get("mime_type", "video/x-unknown")
        entry = singleclick._build_entry(url, mime_type, download_dict)
        singleclick.download_video(entry)
        # it's all async, so we don't know right away
        return False
Esempio n. 7
0
    def handle_download(self, download_dict, parent_folder):
        """
        Download subscriptions look like::

            {
            'type': 'download',
            'url': URL of the file to download
            'title': name of the download (optional),
            'link': page representing this download (optional),
            'feed': RSS feed containing this item (optional),
            'mime_type': the MIME type of the item (optional),
            'description': a description of the item (optional),
            'thumbnail': a thumbnail image for the item (optional),
            'length': the length in seconds of the item (optional)
            }
        """
        assert parent_folder is None, "no folders in downloads"
        url = download_dict['url']
        mime_type = download_dict.get('mime_type', 'video/x-unknown')
        entry = singleclick._build_entry(url, mime_type, download_dict)
        singleclick.download_video(entry)
        # it's all async, so we don't know right away
        return False
Esempio n. 8
0
 def make_item(self, url):
     entry = _build_entry(url, 'video/x-unknown')
     item_ = Item(FeedParserValues(entry), feed_id=self.feed.id)
     self.items.append(item_)
Esempio n. 9
0
 def make_item(self, url, title=u'default item title'):
     additional = {'title': title}
     entry = _build_entry(url, 'video/x-unknown', additional)
     item_ = Item(FeedParserValues(entry), feed_id=self.feed.id)
     self.items.append(item_)
Esempio n. 10
0
def fp_values_for_url(url, additional=None):
    return FeedParserValues(_build_entry(url, 'video/x-unknown', additional))
Esempio n. 11
0
 def make_item(self, url, title=u'default item title'):
     additional = {'title': title}
     entry = _build_entry(url, 'video/x-unknown', additional)
     item = models.Item(FeedParserValues(entry), feed_id=self.feed.id)
     return itemsource.DatabaseItemSource._item_info_for(item)
Esempio n. 12
0
 def make_info(self, title):
     additional = {'title': title}
     url = u'http://example.com/'
     entry = _build_entry(url, 'video/x-unknown', additional)
     item = models.Item(FeedParserValues(entry), feed_id=self.feed.id)
     return itemsource.DatabaseItemSource._item_info_for(item)
Esempio n. 13
0
 def make_item(self, url, title=u'default item title'):
     additional = {'title': title}
     entry = _build_entry(url, 'video/x-unknown', additional)
     item = models.Item(FeedParserValues(entry), feed_id=self.feed.id)
     return itemsource.DatabaseItemSource._item_info_for(item)
Esempio n. 14
0
def fp_values_for_url(url):
    return FeedParserValues(_build_entry(url, 'video/x-unknown'))
Esempio n. 15
0
def fp_values_for_url(url, additional=None):
    return FeedParserValues(_build_entry(url, 'video/x-unknown', additional))
Esempio n. 16
0
        return
    from miro.singleclick import _build_entry, download_video

    for track in dom.documentElement.getElementsByTagName('TRACK'):
        url = None
        additional = {}
        for node in track.childNodes:
            if node.nodeType != node.TEXT_NODE:
                key = node.nodeName
                if node.childNodes:
                    value = node.childNodes[0].nodeValue
                else:
                    value = None
                if key == 'TRACKURL':
                    url = value
                elif key == 'TITLE':
                    additional['title'] = value
                elif key == 'ALBUMARTLARGE':
                    additional['thumbnail'] = value
                elif key == 'ALBUMART' and 'thumbnail' not in additional:
                    additional['thumbnail'] = value
                elif key == 'DURATION':
                    additional['length'] = int(value)
        if url is None:
            app.controller.failed_soft("_emx_callback",
                                       "could not find URL for track",
                                       with_exception=False)
        else:
            entry = _build_entry(url, 'audio/mp3', additional)
            download_video(entry)
Esempio n. 17
0
 def make_item(self, url, title=u'default item title'):
     additional = {'title': title}
     entry = _build_entry(url, 'video/x-unknown', additional)
     item_ = Item(FeedParserValues(entry), feed_id=self.feed.id)
     self.items.append(item_)
Esempio n. 18
0
 def make_item(self, url):
     entry = _build_entry(url, 'video/x-unknown')
     item_ = Item(FeedParserValues(entry), feed_id=self.feed.id)
     self.items.append(item_)
Esempio n. 19
0
 def make_item(self, url, title=u'default item title'):
     additional = {'title': title}
     entry = _build_entry(url, 'video/x-unknown', additional)
     item = models.Item(FeedParserValues(entry), feed_id=self.feed.id)
     self.searcher.add_item(self.make_info(item))
     return item
Esempio n. 20
0
 def make_item(self, url, title=u'default item title'):
     additional = {'title': title}
     entry = _build_entry(url, 'video/x-unknown', additional)
     item = models.Item(FeedParserValues(entry), feed_id=self.feed.id)
     self.searcher.add_item(self.make_info(item))
     return item
Esempio n. 21
0
 def make_info(self, title):
     additional = {'title': title}
     url = u'http://example.com/'
     entry = _build_entry(url, 'video/x-unknown', additional)
     item = models.Item(FeedParserValues(entry), feed_id=self.feed.id)
     return itemsource.DatabaseItemSource._item_info_for(item)