Example #1
0
 def _build_display_name(self, uncached=False):
     if uncached:
         color = 'green' if self.active_download else 'red'
         display = '[B]FURK[/B] | %s' % (
             '[COLOR=green][B]ACTIVE[/B][/COLOR]' if self.active_download
             else '[COLOR=red][B]UNCACHED[/B][/COLOR]')
     else:
         display = '[B]FURK[/B] | PACK [B](x%02d)[/B]' % int(
             self.files_num_video) if int(
                 self.files_num_video) > 3 else '[B]FURK[/B] | SINGLE'
     quality = '[I]{}[/I] '.format(
         self.video_quality) if self.video_quality in (
             'SD', 'CAM', 'TELE',
             'SCR') else '[I][B]{}[/B][/I] '.format(self.video_quality)
     if uncached:
         return '[COLOR={0}]{1} | {2} | {3} | [COLOR={4}][I]{5}[/I][/COLOR][/COLOR]'.format(
             self.provider_color,
             display.upper().replace('RED',
                                     'red').replace('GREEN', 'green'),
             quality.upper(), self.details.upper(), color,
             clean_file_name(self.file_name).upper().replace(
                 'RED', 'red').replace('GREEN', 'green')).replace(
                     self.provider_color.upper(), self.provider_color)
     display_name = '[COLOR={0}]{1} | {2} | {3}[/COLOR]'.format(
         self.provider_color,
         display.upper().replace('RED', 'red').replace('GREEN', 'green'),
         quality.upper(),
         self.details.upper()).replace(self.provider_color.upper(),
                                       self.provider_color)
     if self.show_filenames:
         display_name += '[COLOR={0}] | [I]{1}[/I][/COLOR]'.format(
             self.provider_color,
             clean_file_name(self.file_name).upper())
     return display_name
Example #2
0
def furk_tfile_audio():
    window.clearProperty('furk_t_files_json')
    params = dict(parse_qsl(sys.argv[2].replace('?', '')))
    excludes = ['', 'cover', 'covers', 'scan', 'scans', 'playlists']
    t_files = Furk.t_files(params.get('id'))
    item_path_list = sorted(
        list(
            set([
                clean_file_name(i['path']) for i in t_files
                if clean_file_name(i['path']).lower() not in excludes
            ])))
    if not item_path_list:
        if dialog.yesno("Fen Music Player", 'Browse Songs or Play Full Album?',
                        '', '', 'Play Now', 'Browse'):
            return browse_audio_album(t_files, params.get('name'))
        from resources.lib.modules.player import FenPlayer
        FenPlayer().playAudioAlbum(t_files, params.get('name'))
        return browse_audio_album(t_files, params.get('name'))
    for x in item_path_list:
        url_params = {'mode': 'furk.browse_audio_album', 'item_path': x}
        url = build_url(url_params)
        listitem = xbmcgui.ListItem(x.upper())
        listitem.setThumbnailImage(default_furk_icon)
        listitem.setArt({'fanart': fanart})
        xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True)
    t_files_json = json.dumps(t_files)
    window.setProperty('furk_t_files_json', str(t_files_json))
    xbmcplugin.setContent(__handle__, 'files')
    xbmcplugin.endOfDirectory(__handle__)
    setView('view.furk_files')
Example #3
0
 def playAudioAlbum(self, t_files=None, name=None, from_seperate=False):
     import os
     import xbmcaddon
     from resources.lib.modules.utils import clean_file_name, batch_replace, to_utf8
     from resources.lib.modules.nav_utils import setView
     __addon_id__ = 'plugin.video.fen'
     __addon__ = xbmcaddon.Addon(id=__addon_id__)
     __handle__ = int(sys.argv[1])
     addon_dir = xbmc.translatePath(__addon__.getAddonInfo('path'))
     icon_directory = settings.get_theme()
     default_furk_icon = os.path.join(icon_directory, 'furk.png')
     formats = ('.3gp', ''), ('.aac', ''), ('.flac', ''), ('.m4a', ''), ('.mp3', ''), \
     ('.ogg', ''), ('.raw', ''), ('.wav', ''), ('.wma', ''), ('.webm', ''), ('.ra', ''), ('.rm', '')
     params = dict(parse_qsl(sys.argv[2].replace('?', '')))
     furk_files_list = []
     playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
     playlist.clear()
     if from_seperate:
         t_files = [
             i for i in t_files
             if clean_file_name(i['path']) == params.get('item_path')
         ]
     for item in t_files:
         try:
             name = item['path'] if not name else name
             if not 'audio' in item['ct']: continue
             url = item['url_dl']
             track_name = clean_file_name(
                 batch_replace(to_utf8(item['name']), formats))
             listitem = xbmcgui.ListItem(track_name)
             listitem.setThumbnailImage(default_furk_icon)
             listitem.setInfo(type='music',
                              infoLabels={
                                  'title':
                                  track_name,
                                  'size':
                                  int(item['size']),
                                  'album':
                                  clean_file_name(
                                      batch_replace(to_utf8(name),
                                                    formats)),
                                  'duration':
                                  item['length']
                              })
             listitem.setProperty('mimetype', 'audio/mpeg')
             playlist.add(url, listitem)
             if from_seperate:
                 furk_files_list.append((url, listitem, False))
         except:
             pass
     self.play(playlist)
     if from_seperate:
         xbmcplugin.addDirectoryItems(__handle__, furk_files_list,
                                      len(furk_files_list))
         setView('view.furk_files')
         xbmcplugin.endOfDirectory(__handle__)
Example #4
0
 def _match_media(self, item):
     if clean_file_name(
             self.title).lower() in clean_file_name(item).lower():
         if self.db_type == 'movie':
             if item.split('(')[1][:4] in self._year_query_list():
                 return item
         else:
             return item
     else:
         return None
Example #5
0
 def playback_prep(self, vid_type, tmdb_id, query, tvshowtitle=None, season=None, episode=None, ep_name=None, plot=None, meta=None, from_library=False, background='false'):
     self.background = True if background == 'true' else False
     self.from_library = from_library
     self.widget = False if 'plugin' in xbmc.getInfoLabel('Container.PluginName') else True
     self.action = 'XBMC.Container.Update(%s)' if not self.widget else 'XBMC.RunPlugin(%s)'
     self.use_dialog = True if self.from_library or self.widget else settings.use_dialog()
     self.autoplay = settings.auto_play()
     self.prefer_hevc = settings.prefer_hevc()
     self.check_library = settings.check_library()
     self.check_downloads = settings.check_downloads()
     self.include_prerelease_results = settings.include_prerelease_results()
     self.include_uncached_results = settings.include_uncached_results()
     self.meta = json.loads(meta) if meta else tikimeta.movie_meta('tmdb_id', tmdb_id) if vid_type == "movie" else tikimeta.tvshow_meta('tmdb_id', tmdb_id)
     self.vid_type = vid_type
     self.tmdb_id = tmdb_id
     self.season = int(season) if season else ''
     self.episode = int(episode) if episode else ''
     display_name = clean_file_name(urllib.unquote(query)) if vid_type == 'movie' else '%s - %dx%.2d' % (self.meta['title'], self.season, self.episode)
     if from_library: self.meta.update({'plot': plot, 'from_library': from_library, 'ep_name': ep_name})
     self.meta.update({'query': query, 'vid_type': self.vid_type, 'media_id': self.tmdb_id,
         'rootname': display_name, 'tvshowtitle': self.meta['title'], 'season': self.season,
         'episode': self.episode, 'background': self.background})
     self.search_info = self._search_info()
     self._clear_sources()
     window.setProperty('fen_media_meta', json.dumps(self.meta))
     self.get_sources()
Example #6
0
 def furkTFile(self, file_id):
     from resources.lib.modules.furk_api import FurkAPI
     from resources.lib.indexers.furk import get_release_quality
     hide_busy_dialog()
     close_all_dialog()
     t_files = FurkAPI().t_files(file_id)
     t_files = [i for i in t_files if 'video' in i['ct'] and 'bitrate' in i]
     meta = json.loads(window.getProperty('fen_media_meta'))
     from_library = meta.get('from_library', False)
     not_widget = xbmc.getInfoLabel('Container.PluginName')
     use_dialog = True if from_library or not not_widget else settings.use_dialog()
     display_list = []
     if use_dialog:
         display_list = ['%02d | [B]%s[/B] | [B]%.2f GB[/B] | [I]%s[/I]' % \
                         (count, get_release_quality(i['name'], i['url_dl'], t_file='yep')[0],
                         float(i['size'])/1073741824,
                         clean_file_name(i['name']).upper()) for count, i in enumerate(t_files, 1)]
         chosen = dialog.select("Fen Results", display_list)
         if chosen < 0: return None
         chosen_result = t_files[chosen]
         url_dl = chosen_result['url_dl']
         from resources.lib.modules.player import FenPlayer
         return FenPlayer().run(url_dl)
     for count, item in enumerate(t_files, 1):
         try:
             cm = []
             url_params = {'mode': 'media_play', 'url': item['url_dl']}
             url = build_url(url_params)
             name = clean_file_name(item['name'])
             video_quality, video_type = get_release_quality(item['name'], item['url_dl'], t_file='yep')
             json_meta = json.dumps(meta)
             display_name = '%02d | [B]%s[/B] | [B]%s[/B] | [B]%.2f GB[/B] | [I]%s[/I]' % (count, video_quality, video_type, float(item['size'])/1073741824, name.upper())
             listitem = xbmcgui.ListItem(display_name)
             listitem.setArt({'poster': meta.get('poster', ''), 'thumb': meta.get('poster', ''), 'fanart': meta.get('fanart')})
             playback_params = {'mode': 'playback_menu', 'from_results': True}
             down_file_params = {'mode': 'download_file', 'name': item['name'], 'url': item['url_dl'], 'meta': json_meta}
             cm.append(("[B]Options[/B]",'XBMC.RunPlugin(%s)' % build_url(playback_params)))
             cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params)))
             listitem.addContextMenuItems(cm)
             if meta.get('vid_type') == 'movie': listitem.setInfo('video', {'title': meta.get('title', ''), 'year': meta.get('year', ''), 'plot': meta.get('plot', '')})
             else: listitem.setInfo('video', {'title': meta['rootname'], 'plot': meta.get('plot', '')})
             xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True)
         except: pass
     xbmcplugin.setContent(__handle__, 'files')
     xbmcplugin.endOfDirectory(__handle__)
     setView('view.pack_results')
Example #7
0
def search_easynews():
    from resources.lib.modules.history import add_to_search_history
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    default = params.get('suggestion', '')
    search_title = clean_file_name(params.get('query')) if ('query' in params and params.get('query') != 'NA') else None
    if not search_title: search_title = dialog.input('Enter search Term', type=xbmcgui.INPUT_ALPHANUM, defaultt=default)
    if not search_title: return
    try:
        search_name = clean_file_name(urllib.unquote(search_title))
        add_to_search_history(search_name, 'easynews_video_queries')
        files = EasyNews.search(search_name)
        if not files: return dialog.ok('No results', 'No results')
        files = files[0:int(__addon__.getSetting('easynews_limit'))]
        easynews_file_browser(files)
    except: pass
    xbmcplugin.setContent(__handle__, 'files')
    xbmcplugin.endOfDirectory(__handle__)
    setView('view.easynews_files')
Example #8
0
 def _search_name(self):
     search_title = clean_file_name(self.info.get("title"))
     db_type = self.info.get("db_type")
     year = self.info.get("year")
     years = '%s,%s,%s' % (str(int(year - 1)), year, str(int(year + 1)))
     season = self.info.get("season")
     episode = self.info.get("episode")
     if db_type == 'movie': search_name = '"%s" %s' % (search_title, years)
     else:
         search_name = '%s S%02dE%02d' % (search_title, int(season),
                                          int(episode))
     return search_name
Example #9
0
def furk_tfile_video():
    params = dict(parse_qsl(sys.argv[2].replace('?', '')))
    t_files = [
        i for i in Furk.t_files(params.get('id'))
        if 'video' in i['ct'] and 'bitrate' in i
    ]
    for count, item in enumerate(t_files, 1):
        try:
            cm = []
            url_params = {
                'mode': 'media_play',
                'url': item['url_dl'],
                'rootname': 'nill'
            }
            url = build_url(url_params)
            name = clean_file_name(item['name']).upper()
            if 1200 < int(item['height']) > 2100: display_res = '2160p'
            elif 1000 < int(item['height']) < 1200: display_res = '1080p'
            elif 680 < int(item['height']) < 1000: display_res = 'HD'
            else: display_res = 'SD'
            display_name = '%02d | [B]%s[/B] | [B]%.2f GB[/B] | %smbps | [I]%s[/I]' % \
            (count, display_res, float(item['size'])/1073741824, str(round(float(item['bitrate'])/1000, 2)), name)
            listitem = xbmcgui.ListItem(display_name)
            down_file_params = {
                'mode': 'download_file',
                'name': item['name'],
                'url': item['url_dl'],
                'db_type': 'furk_file',
                'image': default_furk_icon
            }
            cm.append(("[B]Download File[/B]",
                       'XBMC.RunPlugin(%s)' % build_url(down_file_params)))
            listitem.addContextMenuItems(cm)
            listitem.setThumbnailImage(default_furk_icon)
            listitem.setArt({'fanart': fanart})
            listitem.setInfo(
                'video', {
                    'title': display_name,
                    'size': int(item['size']),
                    'duration': item['length']
                })
            listitem.setProperty("IsPlayable", "true")
            xbmcplugin.addDirectoryItem(__handle__,
                                        url,
                                        listitem,
                                        isFolder=True)
        except:
            pass
    xbmcplugin.setContent(__handle__, 'files')
    xbmcplugin.endOfDirectory(__handle__)
    setView('view.furk_files')
Example #10
0
 def _build_display_name(self):
     display = '[B]EASYNEWS[/B]'
     quality = '[I]{}[/I] '.format(
         self.video_quality) if self.video_quality in (
             'SD', 'CAM', 'TELE',
             'SCR') else '[I][B]{}[/B][/I] '.format(self.video_quality)
     display_name = '[COLOR={0}]{1} | {2} | {3}[/COLOR]'.format(
         self.provider_color, display.upper(), quality.upper(),
         self.details.upper())
     if self.show_filenames:
         display_name += '[COLOR={0}] | [I]{1}[/I][/COLOR]'.format(
             self.provider_color,
             clean_file_name(self.file_name).upper())
     return display_name
Example #11
0
def search_furk():
    from resources.lib.modules.history import add_to_search_history
    params = dict(parse_qsl(sys.argv[2].replace('?', '')))
    default = params.get('suggestion', '')
    search_title = clean_file_name(params.get('query')) if (
        'query' in params and params.get('query') != 'NA') else None
    if not search_title:
        search_title = dialog.input('Enter search Term',
                                    type=xbmcgui.INPUT_ALPHANUM,
                                    defaultt=default)
    if not search_title: return
    try:
        search_name = clean_file_name(urllib.unquote(search_title))
        search_method = 'search' if 'accurate_search' in params else 'direct_search'
        search_setting = 'furk_video_queries' if params.get(
            'db_type') == 'video' else 'furk_audio_queries'
        list_type = 'video' if params.get('db_type') == 'video' else 'audio'
        add_to_search_history(search_name, search_setting)
        files = Furk.direct_search(
            search_name) if search_method == 'direct_search' else Furk.search(
                search_name)
        if not files: return dialog.ok('No results', 'No results')
        if not settings.include_uncached_results():
            try:
                files = [
                    i for i in files
                    if i.get('is_ready', '0') == '1' and i['type'] == list_type
                ]
            except:
                return dialog.ok('No results', 'No results')
        files = files[0:int(__addon__.getSetting('furk.limit'))]
        furk_file_browser(files, params, display_mode='search')
    except:
        pass
    xbmcplugin.setContent(__handle__, 'files')
    xbmcplugin.endOfDirectory(__handle__)
    setView('view.furk_files')
Example #12
0
 def _search_name(self):
     search_title = clean_file_name(self.info.get("title"))
     search_title = search_title.replace(' ', '+')
     db_type = self.info.get("db_type")
     year = self.info.get("year")
     years = '%s+|+%s+|+%s' % (str(int(year - 1)), year, str(int(year + 1)))
     season = self.info.get("season")
     episode = self.info.get("episode")
     if db_type == 'movie':
         search_name = '@name+%s+%s' % (search_title, years)
     else:
         queries = self._seas_ep_query_list(season, episode)
         search_name = '@name+%s+@files+%s+|+%s+|+%s' % (
             search_title, queries[0], queries[1], queries[2])
     return search_name
Example #13
0
def play_trailer(url, all_trailers=[]):
    if all_trailers:
        import xbmcgui
        import json
        from resources.lib.modules.utils import clean_file_name, to_utf8
        all_trailers = to_utf8(json.loads(all_trailers))
        video_choice = xbmcgui.Dialog().select(
            "Youtube Videos...",
            [clean_file_name(i['name']) for i in all_trailers])
        if video_choice < 0: return
        url = 'plugin://plugin.video.youtube/play/?video_id=%s' % all_trailers[
            video_choice].get('key')
    try:
        xbmc.executebuiltin('RunPlugin(%s)' % url)
    except:
        notification('Error Playing Trailer')
Example #14
0
 def add_remove_constants(self):
     from resources.lib.modules.utils import clean_file_name
     meta_action = tikimeta.movie_meta if self.db_type == 'movie' else make_fresh_tvshow_meta
     self.meta = meta_action('tmdb_id', self.tmdb_id)
     self.title = clean_file_name(self.meta['title'])
     self.year = self.meta['year'] if 'year' in self.meta else ''
     self.rootname = '{0} ({1})'.format(
         self.title, self.year) if self.year else self.title
     self.folder = os.path.join(self.path, self.rootname + '/')
     self.nfo_filename = self.rootname + '.nfo' if self.db_type == 'movie' else 'tvshow.nfo'
     self.nfo_filepath = os.path.join(self.folder, self.nfo_filename)
     self.nfo_content = "https://www.themoviedb.org/movie/%s-%s" % (
         str(self.meta['tmdb_id']), self.title.replace(' ', '-')
     ) if self.db_type == 'movie' else "https://www.imdb.com/title/%s/" % str(
         self.meta['imdb_id'])
     self.notify = '[B]%s[/B] added to Subscriptions' if self.action == 'add' else '[B]%s[/B] removed from Subscriptions'
     self.db_action = "INSERT OR IGNORE INTO subscriptions VALUES (?, ?, ?)" if self.action == 'add' else "DELETE FROM subscriptions where db_type=? and tmdb_id=? and title=?"
Example #15
0
def easynews_file_browser(files):
    for count, item in enumerate(files, 1):
        try:
            cm = []
            name = clean_file_name(item['name']).upper()
            url_dl = item['url_dl']
            size = str(round(float(int(item['rawSize']))/1048576000, 1))
            display = '%02d | [B]%s GB[/B] | [I]%s [/I]' % (count, size, name)
            url_params = {'mode': 'media_play', 'url': item['url_dl'], 'rootname': 'nill'}
            url = build_url(url_params)
            down_file_params = {'mode': 'download_file', 'name': item['name'], 'url': item['url_dl'], 'db_type': 'easynews_file', 'image': default_easynews_icon}
            cm.append(("[B]Download File[/B]",'XBMC.RunPlugin(%s)' % build_url(down_file_params)))
            listitem = xbmcgui.ListItem(display)
            listitem.addContextMenuItems(cm)
            listitem.setArt({'thumb': default_easynews_icon, 'fanart': fanart})
            listitem.setInfo(type='video', infoLabels={'title': display, 'size': int(item['rawSize'])})
            xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True)
        except: pass
Example #16
0
 def build_list_object():
     try:
         cm = []
         url_params = {
             'mode': 'media_play',
             'url': item['url_dl'],
             'rootname': 'nill'
         }
         url = build_url(url_params)
         track_name = clean_file_name(
             batch_replace(to_utf8(item['name']), formats)).upper()
         listitem = xbmcgui.ListItem(track_name)
         down_file_params = {
             'mode': 'download_file',
             'name': item['name'],
             'url': item['url_dl'],
             'image': default_furk_icon,
             'db_type': 'furk_file'
         }
         cm.append(("[B]Download File[/B]",
                    'XBMC.RunPlugin(%s)' % build_url(down_file_params)))
         listitem.addContextMenuItems(cm)
         listitem.setThumbnailImage(default_furk_icon)
         listitem.setArt({'fanart': fanart})
         listitem.setInfo(type='music',
                          infoLabels={
                              'title': track_name,
                              'size': int(item['size']),
                              'album': item['path'],
                              'duration': item['length']
                          })
         listitem.setProperty("IsPlayable", "true")
         xbmcplugin.addDirectoryItem(__handle__,
                                     url,
                                     listitem,
                                     isFolder=False)
     except:
         pass
Example #17
0
def furk_file_browser(files, params, display_mode):
    files_num = 'files_num_video' if (
        params.get('list_type') == 'file_get_video'
        or params.get('db_type') == 'video') else 'files_num_audio'
    list_type = 'video' if (params.get('list_type') == 'file_get_video'
                            or params.get('db_type') == 'video') else 'music'
    mode = 'furk.furk_tfile_video' if (
        params.get('list_type') == 'file_get_video'
        or params.get('db_type') == 'video') else 'furk.furk_tfile_audio'
    for count, item in enumerate(files, 1):
        try:
            uncached = True if not 'url_dl' in item else False
            if uncached:
                active_downloads = get_active_downloads()
                mode = 'furk.add_uncached_file'
                if item['info_hash'] in active_downloads:
                    info = '%02d | [COLOR=green][B][ACTIVE][/B][/COLOR] |' % count
                else:
                    info = '%02d | [COLOR=red][B][UNCACHED][/B][/COLOR] |' % count
            name = clean_file_name(item['name']).upper()
            item_id = item['id'] if not uncached else item['info_hash']
            url_dl = item['url_dl'] if not uncached else item['info_hash']
            size = item['size']
            if not uncached:
                is_protected = item.get('is_protected')
                display_size = str(round(float(size) / 1048576000, 1))
                info_unprotected = '[B] %s GB | %s files | [/B]' % (
                    display_size, item[files_num])
                info_protected = '[COLOR=green]%s[/COLOR]' % info_unprotected
                info_search = '%02d | [B]%s GB[/B] | [B]%s files[/B] |' % (
                    count, display_size, item[files_num])
                info = info_search if display_mode == 'search' else info_protected if is_protected == '1' else info_unprotected if is_protected == '0' else None
            display = '%s [I] %s [/I]' % (info, name)
            url_params = {'mode': mode, 'name': name, 'id': item_id}
            url = build_url(url_params)
            cm = []
            if not uncached:
                con_add_favs = {
                    'mode': 'add_to_favourites_audio',
                    'name': name,
                    '_id': item_id,
                    'url_dl': url_dl,
                    'size': size
                }
                con_download_archive = {
                    'mode': 'download_file',
                    'name': item.get("name"),
                    'url': url_dl,
                    'db_type': 'archive',
                    'image': default_furk_icon
                }
                con_remove_files = {
                    'mode': 'furk.remove_from_files',
                    'name': name,
                    'item_id': item_id
                }
                con_protect_files = {
                    'mode': 'furk.myfiles_protect_unprotect',
                    'action': 'protect',
                    'name': name,
                    'item_id': item_id
                }
                con_unprotect_files = {
                    'mode': 'furk.myfiles_protect_unprotect',
                    'action': 'unprotect',
                    'name': name,
                    'item_id': item_id
                }
                con_add_to_files = {
                    'mode': 'furk.add_to_files',
                    'name': name,
                    'item_id': item_id
                }
                if params.get('db_type') == 'audio':
                    cm.append(("[B]Add to Fen Favourites[/B]",
                               'XBMC.RunPlugin(%s)' % build_url(con_add_favs)))
                if display_mode == 'search':
                    cm.append(
                        ("[B]Add to My Files[/B]",
                         'XBMC.RunPlugin(%s)' % build_url(con_add_to_files)))
                cm.append(
                    ("[B]Download Archive[/B]",
                     'XBMC.RunPlugin(%s)' % build_url(con_download_archive)))
                cm.append(("[B]Remove from My Files[/B]",
                           'XBMC.RunPlugin(%s)' % build_url(con_remove_files)))
                if is_protected == '0':
                    cm.append(
                        ("[B]Protect File[/B]",
                         'XBMC.RunPlugin(%s)' % build_url(con_protect_files)))
                if is_protected == '1':
                    cm.append(("[B]Unprotect File[/B]", 'XBMC.RunPlugin(%s)' %
                               build_url(con_unprotect_files)))
            listitem = xbmcgui.ListItem(display)
            listitem.addContextMenuItems(cm)
            listitem.setArt({'thumb': default_furk_icon, 'fanart': fanart})
            listitem.setInfo(type=list_type,
                             infoLabels={
                                 'title': display,
                                 'size': int(size)
                             })
            xbmcplugin.addDirectoryItem(__handle__,
                                        url,
                                        listitem,
                                        isFolder=True)
        except:
            pass
Example #18
0
def browse_audio_album(t_files=None, name=None):
    def build_list_object():
        try:
            cm = []
            url_params = {
                'mode': 'media_play',
                'url': item['url_dl'],
                'rootname': 'nill'
            }
            url = build_url(url_params)
            track_name = clean_file_name(
                batch_replace(to_utf8(item['name']), formats)).upper()
            listitem = xbmcgui.ListItem(track_name)
            down_file_params = {
                'mode': 'download_file',
                'name': item['name'],
                'url': item['url_dl'],
                'image': default_furk_icon,
                'db_type': 'furk_file'
            }
            cm.append(("[B]Download File[/B]",
                       'XBMC.RunPlugin(%s)' % build_url(down_file_params)))
            listitem.addContextMenuItems(cm)
            listitem.setThumbnailImage(default_furk_icon)
            listitem.setArt({'fanart': fanart})
            listitem.setInfo(type='music',
                             infoLabels={
                                 'title': track_name,
                                 'size': int(item['size']),
                                 'album': item['path'],
                                 'duration': item['length']
                             })
            listitem.setProperty("IsPlayable", "true")
            xbmcplugin.addDirectoryItem(__handle__,
                                        url,
                                        listitem,
                                        isFolder=False)
        except:
            pass

    from resources.lib.modules.utils import batch_replace
    formats = ('.3gp', ''), ('.aac', ''), ('.flac', ''), ('.m4a', ''), (
        '.mp3', ''), ('.ogg', ''), ('.raw',
                                    ''), ('.wav',
                                          ''), ('.wma',
                                                ''), ('.webm',
                                                      ''), ('.ra', ''), ('.rm',
                                                                         '')
    params = dict(parse_qsl(sys.argv[2].replace('?', '')))
    seperate = False
    if not t_files:
        seperate = True
        t_fs = window.getProperty('furk_t_files_json')
        t_files = json.loads(t_fs)
    t_files = [i for i in t_files if 'audio' in i['ct']]
    if seperate:
        if dialog.yesno("Fen Music Player", 'Browse Songs or Play Full Album?',
                        '', '', 'Play Now', 'Browse'):
            for item in t_files:
                item_path = clean_file_name(item['path'])
                if item_path == params.get('item_path'):
                    build_list_object()
            xbmcplugin.endOfDirectory(__handle__)
            setView('view.furk_files')
        else:
            from resources.lib.modules.player import FenPlayer
            FenPlayer().playAudioAlbum(t_files, from_seperate=True)
    else:
        for item in t_files:
            build_list_object()
        xbmcplugin.setContent(__handle__, 'files')
        xbmcplugin.endOfDirectory(__handle__)
        setView('view.furk_files')
Example #19
0
    def _get_library_video(self, db_type, title, year, season=None, episode=None):
        try:
            name = None
            years = (str(year), str(int(year)+1), str(int(year)-1))
            if db_type == 'movie':
                r = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"filter":{"or": [{"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}]}, "properties": ["imdbnumber", "title", "originaltitle", "file"]}, "id": 1}' % years)
                r = to_utf8(r)
                r = json.loads(r)['result']['movies']
                try:
                    r = [i for i in r if clean_file_name(title).lower() in clean_file_name(to_utf8(i['title'])).lower()]
                    r = [i for i in r if not to_utf8(i['file']).endswith('.strm')][0]
                except: return None
                r = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"properties": ["streamdetails", "file"], "movieid": %s }, "id": 1}' % str(r['movieid']))
                r = to_utf8(r)
                r = json.loads(r)['result']['moviedetails']
            else:
                r = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"filter":{"or": [{"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}]}, "properties": ["title"]}, "id": 1}' % years)
                r = to_utf8(r)
                r = json.loads(r)['result']['tvshows']
                try:
                    r = [i for i in r if clean_file_name(title).lower() in (clean_file_name(to_utf8(i['title'])).lower() if not ' (' in to_utf8(i['title']) else clean_file_name(to_utf8(i['title'])).lower().split(' (')[0])][0]
                except: return None

                r = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"filter":{"and": [{"field": "season", "operator": "is", "value": "%s"}, {"field": "episode", "operator": "is", "value": "%s"}]}, "properties": ["file"], "tvshowid": %s }, "id": 1}' % (str(season), str(episode), str(r['tvshowid'])))
                r = to_utf8(r)
                r = json.loads(r)['result']['episodes']
                try:
                    r = [i for i in r if not to_utf8(i['file']).endswith('.strm')][0]
                except:
                    return None
                r = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodeDetails", "params": {"properties": ["streamdetails", "file"], "episodeid": %s }, "id": 1}' % str(r['episodeid']))
                r = to_utf8(r)
                r = json.loads(r)['result']['episodedetails']
            url = r['file'].encode('utf-8')
            try: name = url.split('/')[-1:][0]
            except: name = None
            if not name:
                try: name = url.split('\\')[-1:][0]
                except: name = None
            if not name:
                name = title
            try: quality = int(r['streamdetails']['video'][0]['width'])
            except: quality = -1
            if quality > 1920: quality = '4K'
            if quality >= 1920: quality = '1080p'
            if 1280 <= quality < 1900: quality = '720p'
            if quality < 1280: quality = 'SD'
            release_details = []
            try:
                f = xbmcvfs.File(url) ; s = f.size() ; f.close()
                s = '%.2f GB' % (float(s)/1024/1024/1024)
                release_details.append(s)
            except: pass
            try:
                c = r['streamdetails']['video'][0]['codec']
                if c == 'avc1': c = 'h264'
                release_details.append(c)
            except: pass
            try:
                ac = r['streamdetails']['audio'][0]['codec']
                if ac == 'dca': ac = 'dts'
                if ac == 'dtshd_ma': ac = 'dts-hd ma'
                release_details.append(ac)
            except: pass
            try:
                ach = r['streamdetails']['audio'][0]['channels']
                if ach == 1: ach = 'mono'
                if ach == 2: ach = '2.0'
                if ach == 6: ach = '5.1'
                if ach == 8: ach = '7.1'
                release_details.append(ach)
            except: pass
            release_details = ' | '.join(release_details)
            release_details = release_details.encode('utf-8')
            return {'name': name, 'file_id': url, 'quality': quality, 'details': release_details}
        except: pass