コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #5
0
ファイル: amazon.py プロジェクト: CodeforEvolution/miro
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)
コード例 #6
0
ファイル: subscription.py プロジェクト: nxmirrors/miro
    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
コード例 #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
コード例 #8
0
ファイル: messagetest.py プロジェクト: ShriramK/miro
 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_)
コード例 #9
0
ファイル: messagetest.py プロジェクト: ShriramK/miro
 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_)
コード例 #10
0
ファイル: itemtest.py プロジェクト: nicolasembleton/miro
def fp_values_for_url(url, additional=None):
    return FeedParserValues(_build_entry(url, 'video/x-unknown', additional))
コード例 #11
0
ファイル: searchtest.py プロジェクト: ShriramK/miro
 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)
コード例 #12
0
ファイル: searchtest.py プロジェクト: ShriramK/miro
 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)
コード例 #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)
コード例 #14
0
ファイル: itemtest.py プロジェクト: cool-RR/Miro
def fp_values_for_url(url):
    return FeedParserValues(_build_entry(url, 'video/x-unknown'))
コード例 #15
0
ファイル: itemtest.py プロジェクト: CodeforEvolution/miro
def fp_values_for_url(url, additional=None):
    return FeedParserValues(_build_entry(url, 'video/x-unknown', additional))
コード例 #16
0
ファイル: emusic.py プロジェクト: youprofit/miro
        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)
コード例 #17
0
ファイル: messagetest.py プロジェクト: kmshi/miro
 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_)
コード例 #18
0
ファイル: messagetest.py プロジェクト: kmshi/miro
 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_)
コード例 #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
コード例 #20
0
ファイル: searchtest.py プロジェクト: ShriramK/miro
 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
コード例 #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)