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)
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)
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)
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)
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)
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
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
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)