Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Check-in [c669dbae79]

Overview
Comment:New plugin: cache reset (temp m3u/pls files, favicons, and channel.json files)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c669dbae79adc70ecef0b45f3867a684c377a185
User & Date: mario on 2016-12-10 22:13:05
Other Links: manifest | tags
Context
2016-12-10
23:17
Make timer warning background orange check-in: 9f078dbb00 user: mario tags: trunk
22:13
New plugin: cache reset (temp m3u/pls files, favicons, and channel.json files) check-in: c669dbae79 user: mario tags: trunk
17:55
Fix `module = __name__` setting. (The .module attribute is still not avoidable, used too widely in GenericChannel etc.) check-in: fbfe51ec5f user: mario tags: trunk
Changes

Added contrib/cachereset.py version [4ffd1ffb9c].



























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# encoding: UTF-8
# api: streamtuner2
# title: Cache Reset
# description: Allows to empty cached stations and favicons
# version: 0.2
# type: feature
# category: config
# priority: optional
# hooks: config_load
#
# Inserts a [Cache Reset] button into the Options tab. Allows
# to either clear channel caches and/or stored favicons.


from config import *
from channels import *
import ahttp
from uikit import *
import action
import re
import os


# provides another export window, and custom file generation - does not use action.save()
class cachereset():

    meta = plugin_meta()
    module = __name__

    # Register in configwin
    def __init__(self, parent):
        # hook
        if not parent:
            return
        parent.hooks["config_load"].append(self.dialog_update)
        
        # add vbox
        hbox = gtk.HBox(False)
        btn = gtk.Button("Cache reset")
        btn.connect("clicked", self.execute)
        self.t1 = gtk.CheckButton("Channels __KB")
        self.t2 = gtk.CheckButton("Icons __KB")
        self.t3 = gtk.CheckButton("Temp __KB")
        hbox.pack_start(btn, True, True, 5)
        hbox.pack_start(self.t1, False, False, 10)
        hbox.pack_start(self.t2, False, False, 10)
        hbox.pack_start(self.t3, False, False, 10)
        parent.vbox1options.pack_start(hbox)
        self.l1 = self.t1.get_children()[0]
        self.l2 = self.t2.get_children()[0]
        self.l3 = self.t3.get_children()[0]
        

    # Update size labels
    def dialog_update(self, *w):
        s1 = self.foldersize(conf.dir + "/cache") / 1024
        s2 = self.foldersize(conf.dir + "/icons") / 1024
        s3 = self.foldersize(conf.tmp) / 1024
        self.l1.set_text("Channels (%s KB)" % s1)
        self.l2.set_text("Icons (%s KB)" % s2)
        self.l3.set_text("Temp (%s KB)" % s3)

    # Calculate folder size (flat dir)
    def foldersize(self, p):
        return sum([os.path.getsize(p+"/"+fn) for fn in os.listdir(p)])

    # Actually delete stuff
    def execute(self, *w):
        for dir, btn in [(conf.dir+"/cache/", self.t1), (conf.dir+"/icons/", self.t2), (conf.tmp+"/", self.t3)]:
            # check if checked
            if not btn.get_state():
                continue
            # list dir + delete files
            for fn in os.listdir(dir):
                os.unlink(dir + fn)
            open(dir + ".nobackup", "a").close()
            self.dialog_update()