Esempio n. 1
0
def export_strm(row_id, export_path=None):
    if export_path is None:
        export_path = kodi.get_setting('export_path_strm')
        if not export_path:
            export_path = kodi.Dialog().browse(3,
                                               kodi.i18n('export_path_strm'),
                                               'files', '', False, False)
            kodi.set_setting('export_path_strm', export_path)
    if export_path:
        default_filename = ''
        play_history = PlayHistory()
        rows = play_history.get(row_id=row_id)
        if rows:
            url, content_type, title, thumb = rows[0]
            default_filename = kodi.string_to_filename(title) + '.strm'
        strm_name = kodi.get_keyboard(kodi.i18n('strm_filename'),
                                      default_filename)
        if strm_name:
            if export_path.startswith('special://'):
                if not export_path.endswith('/'):
                    export_path += '/'
                    kodi.set_setting('export_path_strm', export_path)
                strm_file = kodi.translate_path(export_path + strm_name)
            else:
                strm_file = os.path.join(export_path, strm_name)
            STRMUtils(strm_file).export(row_id)
Esempio n. 2
0
def export_m3u(export_path=None, from_list='history', ctype='video'):
    if export_path is None:
        export_path = kodi.get_setting('export_path')
        if not export_path:
            export_path = kodi.Dialog().browse(3, kodi.i18n('export_path'),
                                               'files', '', False, False)
            kodi.set_setting('export_path', export_path)
    if export_path:
        m3u_name = kodi.get_keyboard(kodi.i18n('m3u_filename'), '')
        if m3u_name:
            if export_path.startswith('special://'):
                if not export_path.endswith('/'):
                    export_path += '/'
                    kodi.set_setting('export_path', export_path)
                m3u_file = kodi.translate_path(export_path + m3u_name)
            else:
                m3u_file = os.path.join(export_path, m3u_name)
            M3UUtils(m3u_file, from_list).export(ctype=ctype)
Esempio n. 3
0
 def use_directory():
     if kodi.get_setting('history-list-type') == '1':
         return True
     else:
         return False
Esempio n. 4
0
 def size_limit():
     return int(kodi.get_setting('history-size-limit'))
Esempio n. 5
0
    def history_directory(self, ctype):
        icon_path = kodi.get_icon()
        fanart_path = kodi.get_fanart()
        total_items = None
        if self.size_limit() != 0:
            _queries = self.get(include_ids=True)
            queries = []
            for index, (row_id, item, content_type, label,
                        thumbnail) in enumerate(_queries):
                if content_type == ctype:
                    queries += [_queries[index]]
            if len(queries) > 0:
                total_items = len(queries)

                can_remote_send = HttpJSONRPC().has_connection_details
                resolve_locally = kodi.get_setting('resolve-locally') == 'true'

                for row_id, item, content_type, label, thumbnail in queries:
                    play_path = {
                        'mode': MODES.PLAY,
                        'player': 'false',
                        'history': 'false',
                        'path': quote(item),
                        'thumb': quote(thumbnail)
                    }
                    if ctype == 'image':
                        play_path = item
                    menu_items = [(kodi.i18n('new_'), 'RunPlugin(%s)' %
                                   (kodi.get_plugin_url({
                                       'mode': MODES.NEW,
                                       'player': 'true'
                                   }))),
                                  (kodi.i18n('manage'),
                                   'Container.Update(%s)' %
                                   (kodi.get_plugin_url({
                                       'mode': MODES.MANAGE_MENU,
                                       'row_id': row_id,
                                       'title': quote(label)
                                   }))),
                                  (kodi.i18n('export'),
                                   'Container.Update(%s)' %
                                   (kodi.get_plugin_url({
                                       'mode': MODES.EXPORT_MENU,
                                       'row_id': row_id,
                                       'ctype': content_type
                                   }))),
                                  (kodi.i18n('clear_history'),
                                   'RunPlugin(%s)' % (kodi.get_plugin_url(
                                       {
                                           'mode': MODES.CLEARHISTORY,
                                           'ctype': content_type
                                       }))),
                                  (kodi.i18n('refresh'), 'Container.Refresh')]

                    if can_remote_send:
                        if resolve_locally:
                            send_path = {
                                'mode': MODES.PLAY,
                                'path': quote(item),
                                'thumb': quote(thumbnail),
                                'title': quote(label),
                                'player': 'remote'
                            }
                        else:
                            send_path = {
                                'mode': MODES.SENDREMOTE,
                                'path': quote(item),
                                'thumb': quote(thumbnail),
                                'title': quote(label)
                            }
                        menu_items.append((kodi.i18n('send_remote_playthis'),
                                           'RunPlugin(%s)' %
                                           (kodi.get_plugin_url(send_path))))

                    is_folder = False
                    thumb = icon_path
                    if content_type == 'image':
                        thumb = item
                    if thumbnail:
                        thumb = thumbnail
                    info = {'title': label}
                    if content_type == 'audio':
                        info.update({'mediatype': 'song'})
                    elif content_type == 'video':
                        info.update({'mediatype': 'video'})
                    elif content_type == 'executable':
                        is_folder = True
                        play_path['player'] = 'true'

                    log_utils.log(
                        'Creating item |{2}|: path |{0}| content type |{1}|'.
                        format(play_path, content_type,
                               label), log_utils.LOGDEBUG)
                    kodi.create_item(play_path,
                                     label,
                                     thumb=thumb,
                                     fanart=fanart_path,
                                     is_folder=is_folder,
                                     is_playable=True,
                                     total_items=total_items,
                                     menu_items=menu_items,
                                     content_type=content_type,
                                     info=info)
        if not total_items:
            menu_items = [(kodi.i18n('refresh'), 'Container.Refresh')]
            kodi.create_item({
                'mode': MODES.NEW,
                'player': 'true'
            },
                             kodi.i18n('new_'),
                             thumb=icon_path,
                             fanart=fanart_path,
                             is_folder=False,
                             is_playable=False,
                             menu_items=menu_items)
        kodi.end_of_directory(cache_to_disc=False)