Check-in [7ef1553f61]
Comment: | Move __print__ into config, add unified dbg.COLOR codes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7ef1553f61c9abcecfb85ac12064e265 |
User & Date: | mario on 2014-04-07 00:33:43 |
Other Links: | manifest | tags |
2014-04-27
| ||
22:19 | Python3 support back into trunk check-in: 9ecea4fb26 user: mario tags: trunk | |
2014-04-08
| ||
21:16 | rename http to ahttp to avoid conflict with Python3 modules, change .iteritems and xrange, remove same remaining plain print statements check-in: d3b1418bc6 user: mario tags: py3 | |
2014-04-07
| ||
00:33 | Move __print__ into config, add unified dbg.COLOR codes check-in: 7ef1553f61 user: mario tags: trunk | |
2014-04-06
| ||
02:16 | rename ui.xml to gtk2.xml for parity with gtk3.xml; Gtk3 suddenly works with gi 1.33 (well, lots of errors still, but main window ok) check-in: e7a0fb24c8 user: mario tags: trunk | |
Modified _package.epm from [036b8e5906] to [d2e2c94cae].
27 28 29 30 31 32 33 | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | - + + | d 755 root root /usr/share/doc/streamtuner2/contrib - f 644 root root /usr/share/doc/streamtuner2/contrib/streamripper_addgenre ./contrib/streamripper_addgenre f 755 root root /usr/bin/streamtuner2 ./st2.py f 644 root root /usr/share/applications/streamtuner2.desktop ./streamtuner2.desktop d 755 root root /usr/share/streamtuner2 - f 644 root root /usr/share/streamtuner2/streamtuner2.png ./streamtuner2.png f 644 root root /usr/share/pixmaps/streamtuner2.png ./logo.png |
Modified action.py from [f63b7b9614] to [fc0650246a].
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | - + - - - - - - | # # import re import os import http |
Modified channels/__init__.py from [f76e54fd21] to [92d73c2e69].
1 2 3 4 5 6 7 8 | 1 2 3 4 5 6 7 8 | - | # # encoding: UTF-8 # api: python # type: R # from channels._generic import * |
Modified channels/_generic.py from [d30d0357de] to [f927301f5f].
18 19 20 21 22 23 24 | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | - + - | # file. They derive from the ChannelPlugins class instead, which # adds the required gtk Widgets manually. # import gtk from mygtk import mygtk |
205 206 207 208 209 210 211 | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | - + | #if (self.liststore.has_key(category)): # del self.liststore[category] else: # parse error self.parent.status("category parsed empty.") self.streams[category] = [{"title":"no contents found on directory server","bitrate":0,"max":0,"listeners":0,"playing":"error","favourite":0,"deleted":0}] |
300 301 302 303 304 305 306 | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | - - + + - - - + - + - + | self.load(self.current, force=1) def switch(self): self.load(self.current, force=0) # display .current category, once notebook/channel tab is first opened def first_show(self): |
527 528 529 530 531 532 533 | 524 525 526 527 528 529 530 531 532 533 | - - - - - - - - - - - | # add module to list #parent.channels[module] = None #parent.channel_names.append(module) """ -> already taken care of in main.load_plugins() """ |
Modified channels/global_key.py from [7c03f6331b] to [3bfb69eda6].
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | - | # # Binds a key to global desktop (F13 = left windows key). On keypress # it switches the currently playing radio station to another one in # bookmarks list. # # Valid key names are for example F9, <Ctrl>G, <Alt>R, <Super>N # |
Modified channels/internet_radio_org_uk.py from [5a7ebd0c8e] to [4dcc6f65d4].
10 11 12 13 14 15 16 | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | - + | # # from channels import * import re |
Modified channels/live365.py from [9e6de8cad1] to [17860a6a46].
8 9 10 11 12 13 14 | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | - + | # streamtuner2 modules from config import conf from mygtk import mygtk import http from channels import * |
114 115 116 117 118 119 120 | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | - + - + | =["']audioQuality.+?>(\d+)\w<.+? >DrawListenerStars\((\d+),.+? >DrawRatingStars\((\d+),\s+(\d+),.*? """, re.X|re.I|re.S|re.M) # src="(http://www.live365.com/.+?/stationlogo\w+.jpg)".+? # append entries to result list |
Modified channels/modarchive.py from [ac3a95273a] to [bf829e8b72].
11 12 13 14 15 16 17 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | - + | # import re import http from config import conf from channels import * |
107 108 109 110 111 112 113 | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | - + | .*? /formats/(\w+).png" .*? title="([^">]+)">([^<>]+)</a> .*? >Rated</a>\s*(\d+) """, re.X|re.S) for uu in rx_mod.findall(html): (url, id, fmt, title, file, rating) = uu |
Modified channels/punkcast.py from [ba986159c3] to [6f838d457b].
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - + | import re import http from config import conf import action from channels import * |
82 83 84 85 86 87 88 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | - + | def play(self, row): rx_sound = re.compile("""(http://[^"<>]+[.](mp3|ogg|m3u|pls|ram))""") html = http.get(row["homepage"]) # look up ANY audio url for uu in rx_sound.findall(html): |
Modified channels/shoutcast.py from [8c7ec7957d] to [3296716516].
1 2 3 4 5 | 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 | - + - + - - - - - - - - - - - - - - - - + + + + - - | # # api: streamtuner2 # title: shoutcast # description: Channel/tab for Shoutcast.com directory # depends: pq, re, http |
73 74 75 76 77 78 79 | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | - + - + - + - + - + - - + + + + + + + + - - + + | # extracts the category list from shoutcast.com, # sub-categories are queried per 'AJAX' def update_categories(self): html = http.get(self.base_url) self.categories = [] |
163 164 165 166 167 168 169 | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | - + + - + - + - + + - - - - + + + - + - + | \s+ <td [^>]+ >([^<>]+)</td> \s+ <td [^>]+ >(\d+)</td> \s+ <td [^>]+ >(\d+)</td> \s+ <td [^>]+ >(\w+)</td> """, re.S|re.I|re.X ) |
Modified channels/xiph.py from [8ad5a64170] to [6bbc72e8d5].
17 18 19 20 21 22 23 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | - + | # streamtuner2 modules from config import conf from mygtk import mygtk import http from channels import * |
86 87 88 89 90 91 92 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | - + | else: g[t] = 0 g = [ [v[1],v[0]] for v in g.items() ] g.sort() g.reverse() for row in g: pass |
Modified config.py from [0a6d293594] to [16fe14f094].
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | - | conf = object() #-- global configuration data --------------------------------------------- class ConfigDict(dict): |
158 159 160 161 162 163 164 | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | - + - + + + + + + + + + + + + + + + + + + + + + | f = open(file, "r") else: return # file not found # decode r = pson.load(f) f.close() return r |
Modified http.py from [68776c8e4a] to [0d4dcfee94].
10 11 12 13 14 15 16 | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | - - - + + + + + + - + | # And a function to add trailings slashes on http URLs. # # The latter code is pretty much unreadable. But let's put the # blame on urllib2, the most braindamaged code in the Python # standard library. # |
Modified mygtk.py from [74d7664de2] to [98fa2cab88].
23 24 25 26 27 28 29 | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | - + - - + | # # # debug |
Modified pson.py from [1f7ebfaebc] to [759da668d2].
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | + + + + | # pygtk-objects crawled into the streams[] lists, because rows # might have been queried from the widgets. # #-- reading and writing json (for the config module) ---------------------------------- import sys if sys.version_info > (2, 9): unicode = str #dict.iteritems = dict.items # try to load the system module first try: from json import dump as json_dump, load as json_load except: print("no native Python JSON module") |
80 81 82 83 84 85 86 | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | - + | elif type(obj) == unicode: return str(obj) elif type(obj) in (list, tuple, set): obj = list(obj) for i,v in enumerate(obj): obj[i] = filter_data(v) elif type(obj) == dict: |
Modified st2.py from [4696fba60c] to [0b9e0b6b81].
95 96 97 98 99 100 101 102 103 104 | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | + - | sys.path.insert(0, ".") # pre-defined directory for modules # gtk modules from mygtk import pygtk, gtk, gobject, ui_file, mygtk # custom modules from config import conf # initializes itself, so all conf.vars are available right away from config import __print__, dbg import http import action # needs workaround... (action.main=main) from channels import * |
126 127 128 129 130 131 132 | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | - + - + - + - + - + - + | current_channel = "bookmarks" # currently selected channel name (as index in self.channels{}) # constructor def __init__(self): # gtkrc stylesheet |
219 220 221 222 223 224 225 | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | - + | "streamedit_open": streamedit.open, "streamedit_save": streamedit.save, "streamedit_new": streamedit.new, "streamedit_cancel": streamedit.cancel, }.items() + self.add_signals.items() )) # actually display main window |
279 280 281 282 283 284 285 | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | - - - + + + - + | self.notebook_channels.set_current_page(self.channel_names.index(page)) # notebook invocation: else: #if type(page_num) == int: self.current_channel = self.channel_names[page_num] # if first selected, load current category try: |
333 334 335 336 337 338 339 | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | - + - + | url = self.selected("homepage") action.browser(url) # browse channel def on_homepage_channel_clicked(self, widget, event=2): if event == 2 or event.type == gtk.gdk._2BUTTON_PRESS: |
363 364 365 366 367 368 369 | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | - + | thread = self.working.pop() thread.stop() # click in category list def on_category_clicked(self, widget, event, *more): category = self.channel().currentcat() |
460 461 462 463 464 465 466 | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | - + - + - + | # resort with tab order order = [module.strip() for module in conf.channel_order.lower().replace(".","_").replace("-","_").split(",")] ls = [module for module in (order) if (module in ls)] + [module for module in (ls) if (module not in order)] # step through for module in ls: |
512 513 514 515 516 517 518 | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | - + | conf.save("state", channelopts, nice=1) # apply gtkrc stylesheet def load_theme(self): if conf.get("theme"): for dir in (conf.dir, conf.share, "/usr/share"): |
772 773 774 775 776 777 778 | 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | - + | # set/load values between gtk window and conf. dict def apply(self, config, prefix="config_", save=0): for key,val in config.iteritems(): # map non-alphanumeric chars from config{} to underscores in according gtk widget names id = re.sub("[^\w]", "_", key) w = main.get_widget(prefix + id) |
795 796 797 798 799 800 801 802 803 | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 | + + + + + + + - + | # fill combobox def combobox_theme(self): # self.theme.combo_box_new_text() # find themes themedirs = (conf.share+"/themes", conf.dir+"/themes", "/usr/share/themes") themes = ["no theme"] [[themes.append(e) for e in os.listdir(dir)] for dir in themedirs if os.path.exists(dir)] __print__(dbg.STAT, themes) # prepare liststore store = gtk.ListStore(gobject.TYPE_STRING) self.theme.set_model(store) cell = gtk.CellRendererText() self.theme.pack_start(cell, True) self.theme.add_attribute(cell, "text", 0) # add to combobox for num,themename in enumerate(themes): |
1004 1005 1006 1007 1008 1009 1010 | 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | - + | self.load(self.default) self.urls.append(row["url"]) # simplified gtk TreeStore display logic (just one category for the moment, always rebuilt) def load(self, category, force=False): #self.liststore[category] = \ |
1099 1100 1101 1102 1103 1104 1105 | 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | - + - + | #-- startup progress bar progresswin, progressbar = 0, 0 |
1147 1148 1149 1150 1151 1152 1153 | 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 | - + - + | # graphical if len(sys.argv) < 2: # prepare for threading in Gtk+ callbacks gobject.threads_init() |