示例#1
0
def copy_album (albenurl):
    pDialog = xbmcgui.DialogProgressBG()
    pDialog.create(_('dialog3'), _('dialog4'))
    AlbumData = _get_album_title (albenurl)
    y = len(AlbumData['tracks'])
    x = 0
    AlbumData['artist'] = forbidden_char(AlbumData['artist'])
    AlbumData['album'] = forbidden_char(AlbumData['album'])
    d = os.path.join(dst, AlbumData['artist'].decode('utf8'), '('+AlbumData['year']+') ' + AlbumData['album'].decode('utf8'))
    adata = get_albumdata (AlbumData['album'],  AlbumData['artist'])
    if adata:
        cover = adata['strAlbumThumb']
        if adata['strGenre']:
            AlbumData['genre'] = adata['strGenre']
        if adata['strArtist']:
            AlbumData['artist'] = adata['strArtist'].encode('utf8')
        if adata['strAlbum']:
            AlbumData['album'] = adata['strAlbum'].encode('utf8')
        if adata['intYearReleased']:
            AlbumData['year'] = adata['intYearReleased']
        if cover:
            copy_file (cover, d, 'folder.{0}'.format(cover.split('.')[-1]))

    for data in AlbumData['tracks']:
        if data['path'][-4:].lower() == '.mp3':
            x += 1
            z = int(float(x) / y * 100)
            pDialog.update (z, 'Download Album - {0} '.format(AlbumData['album']), 'Copy : {0}. {1}'.format(data['no'], data['title'] ))
            fn = '{0} - {1} - {2}.mp3'.format(data['no'], AlbumData['artist'], data['title'])
            fname = copy_file (data['path'], d, fn )
            if fname:
                mp3_tags(fname, AlbumData['artist'], AlbumData['year'], AlbumData['album'], data['no'], AlbumData['tracks'], data['title'],  AlbumData['genre'], AlbumData['comment'])
    pDialog.close()
    return
示例#2
0
        def download():
            with open(dp + '{0}.S{1}.E{2}_{3}.mp4'.format(title.replace(' ', '.').replace('/', '-'), season, ep, quality + 'P'), 'wb') as f:
                download_headers = {  # Required for download speed
                    'Accept-Encoding': 'gzip, deflate, br',
                    'Cache-Control': 'no-cache',
                    'Connection': 'keep-alive',
                    'User-Agent': HEADERS['User-Agent']
                    ,'Cookie': 'Sdarot={0}'.format(cookie.get('Sdarot'), safe='')
                }

                request = urllib2.Request('http:' + url, headers=download_headers)
                response = urllib2.urlopen(request)
                total_size = response.info().get('Content-Length')

                plugin.notify('ההורדה החלה', image=ICON)

                dialog = xbmcgui.DialogProgressBG()
                dialog.create(f.name)
                dialog.update(1)
                dl = 0

                while True:
                    chunk = response.read(1024 * 30)
                    if not chunk:
                        break
                    dl += len(chunk)
                    dialog.update(100 * dl / int(total_size))
                    f.write(chunk)

                dialog.close()
                response.close()

            plugin.notify('{0} עונה {1} פרק {2} ירד בהצלחה!'.format(title, season, ep), delay=8000, image=ICON)
            return True
示例#3
0
def get_popular_albums():
    pDialog = xbmcgui.DialogProgressBG()
    pDialog.create(_('dialog11'), _('dialog12'))
    content = open_url(url +'/album/week.html')
    content = regex_from_to(content, '<div class="albums">', '<div class="copyright">')
    List = regex_get_all(content, '<div class="item', ' </div>')
    items = []
    for i in List:
        infoAnker = regex_get_all(i,'<a href="', '</a>', excluding=False)
        infoAlbum = del_em(regex_from_to(infoAnker[1], '<a href=".*">', '</a>'))
        infoThumb = regex_from_to(infoAnker[0], '<img src="', '"')
        infoPath = regex_from_to(infoAnker[1], '<a href="', '"')

        infoYear = infoAlbum[-5:].replace(')', '')
        infoAlbum = infoAlbum[:len(infoAlbum)-7]

        context_menu = []
        context_menu.append(('[COLOR lime]Download Album[/COLOR]',
            'XBMC.RunPlugin(%s)' % plugin.url_for('copy_album',  albenurl = infoPath)))
        items.append ({
            'label': '({0}) {1}'.format(infoYear, infoAlbum), 
            'path': plugin.url_for('search_album_title', albenurl = infoPath, albenname='('+infoYear+') '+infoAlbum,  thumb=infoThumb ),
            'info': {
                'genre' : None, 
                'artist' : None,
                'year' : infoYear,
                'album' : infoAlbum, 
            }, 
            'thumbnail':  infoThumb,
            'context_menu' : context_menu,
        })
    if extra_info:
        i = 0
        x = 0
        y = len(items)
        for item in items:
            x += 1
            z = int(float(x) / y * 100)
            try:
                pDialog.update (z, _('dialog7'), _('dialog8').format(item['info']['album']))
            except:
                pDialog.update (z, _('dialog7'), _('dialog8').format(item['info']['album'].decode('utf-8')))
            Data = get_albumdata_by_Name (item['info']['album'])
            if Data :
                for ye in Data:
                    if ye['intYearReleased']:
                        if ye['intYearReleased'] == items[i]['info']['year'] :
                            if ye['strAlbum']: items[i]['info']['album'] = ye['strAlbum']
                            if ye['strGenre'] :
                                items[i]['info']['genre'] = ye['strGenre']
                                items[i]['label'] = '({0}) {1} [{2}]'.format(items[i]['info']['year'],  items[i]['info']['album'], ye['strGenre'])
                            if ye['idAlbum'] :
                                AlbumData = get_albumdata_id (ye['idAlbum'])
                                if AlbumData :
                                    if AlbumData['intYearReleased'] : items[i]['info']['year'] = AlbumData['intYearReleased']
                                    if AlbumData['strAlbumThumb'] : items[i]['thumbnail'] = AlbumData['strAlbumThumb']
            i += 1
    pDialog.close()            
    return ( items )
示例#4
0
 def run(self):
     progress = xbmcgui.DialogProgressBG()
     with closing(progress):
         progress.create(lang(40163))
         for src, dst in self.files.iteritems():
             progress.update(0, message=src)
             copying_thread = FileCopyingThread(src, dst, self.delete)
             copying_thread.start()
             while copying_thread.is_alive():
                 sleep(250)
                 progress.update(copying_thread.progress())
         if self.on_finish:
             self.on_finish()
示例#5
0
def update_library():
    plugin.log.info("Starting LostFilm.TV library update...")
    progress = xbmcgui.DialogProgressBG()
    scraper = get_scraper()
    series_ids = library_items()
    if plugin.get_setting('sync_favorites', bool) and plugin.get_setting(
            'enable_sync', bool):
        fav_ids = scraper.get_favorite_series()
        series_ids = list(set(series_ids + fav_ids))
    total = len(series_ids)
    lib = get_library()
    processed = 0
    with closing(progress):
        progress.create(lang(30000), lang(40409))
        series_episodes = {}
        for ids in batch(series_ids, BATCH_SERIES_COUNT):
            series_episodes.update(scraper.get_series_episodes_bulk(ids))
            processed += len(ids)
            progress.update(processed * 100 / total)
            if abort_requested():
                return
        medias = []
        for series_id, episodes in series_episodes.iteritems():
            medias.extend(
                library.Episode(folder=e.series_title,
                                title=e.episode_title.replace(u'й', u'й'),
                                season_number=e.season_number,
                                episode_number=e.episode_numbers,
                                url=episode_url(e),
                                time_added=e.release_date,
                                episode=e) for e in episodes
                if not e.is_complete_season)
        lib.sync(medias)
        new_episodes = library_new_episodes()
        new_episodes |= NewEpisodes(lib.added_medias)
    if plugin.get_setting('update-xbmc-library', bool):
        if lib.added_medias or lib.created_medias or lib.updated_medias:
            plugin.wait_library_scan()
            plugin.log.info("Starting XBMC library update...")
            plugin.update_library('video',
                                  plugin.get_setting('library-path', unicode))
        if lib.removed_files:
            plugin.wait_library_scan()
            plugin.log.info("Starting XBMC library clean...")
            plugin.clean_library('video')
    plugin.log.info("LostFilm.TV library update finished.")
    return lib.added_medias or lib.created_medias or lib.updated_medias or lib.removed_files
示例#6
0
def get_popular_artists():
    pDialog = xbmcgui.DialogProgressBG()
    pDialog.create(_('dialog5'), _('dialog6'))
    content = open_url(url +'/artist.html')
    content = regex_from_to(content, '<div class="list">', '</div>')
    List = regex_get_all(content, '<a href="', '</a>')
    items = []
    for i in List:
        infoPath = regex_from_to(i, '<a href="', '"').replace('artist', 'artist/albums')
        infoThumb = regex_from_to(i, '<img src="', '"')
        infoArtist = del_em(regex_from_to(i, '/>', '</a>'))
        context_menu = []
        items.append ({
            'label': infoArtist, 
            'path': plugin.url_for('search_artist_albums', artist= infoArtist, albenurl = infoPath ),
            'info': {
                'genre' : None, 
                'artist' : infoArtist,
                'year' : None,
                'album' : None, 
            }, 
            'thumbnail':  infoThumb,
            'context_menu' : context_menu,
        })
    if extra_info:
        i = 0
        x = 0
        y = len(items)
        for item in items:
            x += 1
            z = int(float(x) / y * 100)
            try:
                pDialog.update (z, _('dialog7'), _('dialog8').format(item['info']['artist']))
            except:
                pDialog.update (z, _('dialog7'), _('dialog8').format(item['info']['artist'].decode('utf-8')))
            ArtistData = get_artistdata (item['info']['artist'])
            if ArtistData:
                if ArtistData['strArtistThumb']: items[i]['thumbnail'] = ArtistData['strArtistThumb']
                if ArtistData['strGenre'] :
                    items[i]['info']['genre'] = ArtistData['strGenre']
                    items[i]['label'] += ' [{0}]'.format(ArtistData['strGenre'])
            i += 1
    pDialog.close()            
    return ( items )
示例#7
0
def get_popular_tracks():
    pDialog = xbmcgui.DialogProgressBG()
    pDialog.create(_('dialog9'), _('dialog10'))
    content = open_url(url)
#    __log(content)
    content = regex_from_to(content, '<div class="index-songs-artist">', '<div class="hot-artist">')
    List = regex_get_all(content, '<div class="item', '</div>')
#    __log(List)
    items = []
    x = 0
    y = len(List)
    for i in List:
        x += 1
        z = int(float(x) / y * 100)
        infoAnker = regex_get_all(i,'<a href="', '</a>', excluding=False)
        infoArtist = del_em(regex_from_to(infoAnker[1], '<a href=".*">', '</a>')).strip() 
        infoSong = del_em(regex_from_to(infoAnker[0], '<a href=".*">', '</a>')).strip() 
        infoPath = regex_from_to(infoAnker[0], '<a href="', '"').replace('/track', '/download')
        pDialog.update (z, _('dialog13'), _('dialog14').format(infoArtist))
        infoURL = catch_download( url + infoPath)
        if infoURL[-4:].lower()=='.mp3':
            items.append ({
                'label' : '{0} - {1}'.format(infoArtist, infoSong), 
                'path': infoURL,
                'info' : {
                    'tracknumber' : None,  
                    'discnumber' : None, 
                    'duration' : None, 
                    'year' : None, 
                    'genre' : None, 
                    'album' : None,
                    'artist' : infoArtist, 
                    'title' : infoSong, 
                    'rating' : None, 
                    'comment' : None, 
                }, 
                'thumbnail': noImage, 
                'is_playable': True,
            })
    if extra_info:
        i = 0
        x = 0
        y = len(items)
        for item in items:
            x += 1
            z = int(float(x) / y * 100)
            try:
                pDialog.update (z, _('dialog7'), _('dialog8').format(item['info']['artist']))
            except:
                pDialog.update (z, _('dialog7'), _('dialog8').format(item['info']['artist'].decode('utf-8')))
            Data = get_trackdata (item['info']['artist'],  item['info']['title'])
            if Data :
                if Data['strAlbum']: items[i]['info']['album'] = Data['strAlbum']
                if Data['intTrackNumber'] : items[i]['info']['tracknumber'] = Data['intTrackNumber']
                if Data['strGenre'] :
                    items[i]['info']['genre'] = Data['strGenre']
                    items[i]['label'] = '{0} - {1} [{2}]'.format(infoArtist, infoSong, Data['strGenre'])
                if Data['idAlbum'] :
                    AlbumData = get_albumdata_id (Data['idAlbum'])
                    if AlbumData :
                        if AlbumData['intYearReleased'] : items[i]['info']['year'] = AlbumData['intYearReleased']
                        if AlbumData['strAlbumThumb'] : items[i]['thumbnail'] = AlbumData['strAlbumThumb']
            i += 1
    pDialog.close()
    return ( items )
示例#8
0
def get_ArtistAZ_List(char):
    pDialog = xbmcgui.DialogProgressBG()
    pDialog.create(_('dialog5'), _('dialog6'))
    if char == '#':
        Path = '/artist-digital.html'
    else:
        Path = '/artist-{0}.html'.format(char)
    content = open_url(url+Path)
    HList = regex_from_to(content,'<div class="list">', '<div class="item">', excluding=True)
    HotList = regex_get_all(HList,'<a href="', '</a>', excluding=False)
    List = regex_get_all(content,'<div class="item"><span>', '</span>', excluding=True)
    items = []
    for i in HotList:
        try:
            infoArtist = del_em(regex_from_to(i, '/>', '</a>'))
        except:
            __log('infoArtist : {0}'.format(i))
        else:
            infoPath = regex_from_to(i, '<a href="', '"').replace('/artist/' , '/artist/albums/')
            items.append ({
                'label': infoArtist, 
                'path': plugin.url_for('search_artist_albums', artist= infoArtist, albenurl = infoPath ), 
                'thumbnail': noImage, 
                'info': {
                    'artist': infoArtist, 
                    'genre': None, 
                    'comment': None, 
                }, 
            })
    for i in List:
        try:
            infoArtist = del_em(regex_from_to(i, 'class="link">', '</a>'))
        except:
            __log('infoArtist : {0}'.format(i))
        else:
            infoPath = regex_from_to(i, '<a href="', '"').replace('/artist/' , '/artist/albums/')
            items.append ({
                'label': infoArtist, 
                'path': plugin.url_for('search_artist_albums', artist= infoArtist, albenurl = infoPath ), 
                'thumbnail': noImage, 
                'info': {
                    'artist': infoArtist, 
                    'genre': None, 
                    'comment': None, 
                }, 
            })
    if extra_info:
        i = 0
        x = 0
        y = len(items)
        for Data in items:
            x += 1
            z = int(float(x) / y * 100)
            try:
                pDialog.update (z, _('dialog7'), _('dialog8').format(Data['info']['artist']))                
            except:
                pDialog.update (z, _('dialog7'), _('dialog8').format(Data['info']['artist'].decode('utf-8')))
            ExtraData = get_artistdata(Data['info']['artist'])
            if ExtraData:
                items[i]['thumbnail'] = ExtraData.get('strArtistThumb',items[i]['thumbnail'])
                if ExtraData.has_key('strBiographyDE'): items[i]['info']['comment'] = ExtraData['strBiographyDE']
                else :
                    if ExtraData.has_key('strBiographyEN'): items[i]['info']['comment'] = ExtraData['strBiographyEN']
                if ExtraData['strGenre'] and len (ExtraData['strGenre']) >0 :
                    items[i]['info']['genre'] = ExtraData['strGenre']
                    items[i]['label'] = '{0} [{1}]'.format(Data['info']['artist'], ExtraData['strGenre'])
            i += 1
    pDialog.close()
    return (items)