~wattazoum/xbmc/mangas-tv-plugin

« back to all changes in this revision

Viewing changes to plugin.video.mangastv/resources/lib/main_mangastv.py

  • Committer: Oumar Aziz OUATTARA
  • Date: 2011-01-27 20:37:09 UTC
  • Revision ID: aouattara@octo.com-20110127203709-0n4iuo20glguk70x
Tags: 2.2
Nettoyage du cache.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
__addonid__ = 'plugin.video.mangastv'
19
19
__settings__ = xbmcaddon.Addon(id=__addonid__)
20
20
__site_url__ = "http://mangas-tv.com/"
21
 
__version__ = "2.1"
 
21
__version__ = "2.2"
22
22
 
23
23
lang = __settings__.getLocalizedString
24
24
 
30
30
SHOW_EPISODES_MODE = 'showEpisodes' 
31
31
LOGIN_TO_UNLOCK_MODE = 'loginToUnlock'
32
32
SEARCH_MODE = 'search'
 
33
CLEAN_CACHE_MODE = 'cleanCache'
33
34
 
34
35
# Empty cache dir when we change the version
35
36
profile_dir = xbmc.translatePath(__settings__.getAddonInfo('profile'))
63
64
                                                SHOW_EPISODES_MODE: 'episodes',
64
65
                                                PLAY_VIDEO_MODE: 'episodes',
65
66
                                                LOGIN_TO_UNLOCK_MODE: 'files',
 
67
                                                CLEAN_CACHE_MODE: 'files',
66
68
                                                SEARCH_MODE: 'tvshows' }
67
69
        
68
70
        def __init__(self):
317
319
                else:
318
320
                        self.loginToUnlock(main, self.playVideo, True)
319
321
                        
 
322
        def cleanCache(self):
 
323
                if os.path.exists(cache_dir):
 
324
                        shutil.rmtree(cache_dir)
 
325
                        
320
326
        def addItem(self, info, extrainfo=None, isFolder=True, total_items=0):
321
327
                #Defaults in dict. Use 'None' instead of None so it is compatible for quote_plus in parseArgs
322
328
                info.setdefault('url', 'None')
349
355
                        li.setProperty("IsPlayable", "true")#let xbmc know this can be played, unlike a folder.
350
356
                else:
351
357
                        li.setProperty("IsPlayable", "false")
 
358
                        
 
359
                cleanCacheUrl = sys.argv[0] + "?mode=" + CLEAN_CACHE_MODE
 
360
                li.addContextMenuItems([(lang(30047), 'XBMC.RunPlugin(%s)' % cleanCacheUrl)])
 
361
                
352
362
                debug("url = %s" % u)
353
363
                #add item to list
354
364
                xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=li, isFolder=isFolder, totalItems=total_items)
413
423
                elif mode == LOGIN_TO_UNLOCK_MODE:
414
424
                        ui = UI()
415
425
                        ui.loginToUnlock(self, ui.showEpisodes, True)
 
426
                elif mode == CLEAN_CACHE_MODE:
 
427
                        UI().cleanCache()
416
428