@@ -71,8 +71,6 @@ class PyRadioStations(object):
71
71
72
72
jump_tag = - 1
73
73
74
- _browsing_station_service = False
75
-
76
74
# station directory service object
77
75
_online_browser = None
78
76
@@ -133,11 +131,35 @@ def playlist_version(self, value):
133
131
134
132
@property
135
133
def browsing_station_service (self ):
136
- return self ._browsing_station_service
134
+ return self ._ps . browsing_station_service
137
135
138
136
@browsing_station_service .setter
139
137
def browsing_station_service (self , value ):
140
- self ._browsing_station_service = value
138
+ self ._ps .browsing_station_service = value
139
+
140
+ @property
141
+ def history_selection (self ):
142
+ return self ._ps .selection
143
+
144
+ @history_selection .setter
145
+ def history_selection (self , value ):
146
+ self ._ps .selection = value
147
+
148
+ @property
149
+ def history_startPos (self ):
150
+ return self ._ps .startPos
151
+
152
+ @history_startPos .setter
153
+ def history_startPos (self , value ):
154
+ self ._ps .startPos = value
155
+
156
+ @property
157
+ def browsing_station_service (self ):
158
+ return self ._ps .browsing_station_service
159
+
160
+ @browsing_station_service .setter
161
+ def browsing_station_service (self , value ):
162
+ self ._ps .browsing_station_service = value
141
163
142
164
@property
143
165
def stations_file (self ):
@@ -157,7 +179,7 @@ def stations_filename_only(self, value):
157
179
158
180
@property
159
181
def stations_filename_only_no_extension (self ):
160
- return self ._ps .stations_filename_only
182
+ return self ._ps .stations_filename_only_no_extension
161
183
162
184
@stations_filename_only_no_extension .setter
163
185
def stations_filename_only_no_extension (self , value ):
@@ -172,7 +194,7 @@ def can_go_back_in_time(self, value):
172
194
raise ValueError ('property is read only' )
173
195
174
196
def url (self , id_in_list ):
175
- if self ._browsing_station_service :
197
+ if self ._ps . browsing_station_service :
176
198
# TODO get browser url
177
199
return self ._online_browser .url (id_in_list )
178
200
#return self.stations[id_in_list][1].strip()
@@ -511,17 +533,24 @@ def _set_playlist_elements(self, a_playlist, a_title=''):
511
533
512
534
def add_to_playlist_history (self , stations_file = '' ,
513
535
stations_filename_only = '' ,
514
- stations_filename_only_no_extension = '' ):
536
+ stations_filename_only_no_extension = '' ,
537
+ startPos = 0 , selection = 0 , playing = - 1 ,
538
+ browsing_station_service = False ):
515
539
self ._ps .add (stations_file ,
516
540
stations_filename_only ,
517
- stations_filename_only_no_extension )
541
+ stations_filename_only_no_extension ,
542
+ startPos , selection , playing ,
543
+ browsing_station_service )
518
544
519
545
def reset_playlist_history (self ):
520
546
self ._ps .reset ()
521
547
522
548
def remove_from_playlist_history (self ):
523
549
return self ._ps .pop ()
524
550
551
+ def copy_playlist_history (self ):
552
+ return self ._ps .copy ()
553
+
525
554
def _bytes_to_human (self , B ):
526
555
''' Return the given bytes as a human friendly KB, MB, GB, or TB string '''
527
556
KB = float (1024 )
@@ -713,10 +742,11 @@ def open_browser(self, url):
713
742
self .number_of_stations = len (self .stations )
714
743
self .dirty_playlist = False
715
744
716
- def save_station_position (self , startPos , selection ):
745
+ def save_station_position (self , startPos , selection , playing ):
717
746
logger .error ('DE startPos = {0}, selection = {1}' .format (startPos , selection ))
718
747
self ._ps .startPos = startPos
719
748
self ._ps .selection = selection
749
+ self ._ps .playing = playing
720
750
logger .error ('\n \n DE {}\n \n ' .format (self ._ps ._p ))
721
751
722
752
class PyRadioConfig (PyRadioStations ):
@@ -892,7 +922,7 @@ def _check_config_file(self, usr):
892
922
copyfile (package_config_file , user_config_file )
893
923
894
924
def internal_header_height (self ):
895
- if self ._browsing_station_service :
925
+ if self .browsing_station_service :
896
926
return self .online_browser .internal_header_height
897
927
else :
898
928
return 0
@@ -1107,15 +1137,32 @@ class PyRadioPlaylistStack(object):
1107
1137
_p = []
1108
1138
1109
1139
_id = {'stations_file' : 0 ,
1140
+ 'path' : 0 ,
1110
1141
'stations_filename_only' : 1 ,
1142
+ 'filename' : 1 ,
1111
1143
'stations_filename_only_no_extension' : 2 ,
1144
+ 'title' : 2 ,
1112
1145
'startPos' : 3 ,
1113
1146
'selection' : 4 ,
1147
+ 'playing' : 5 ,
1148
+ 'browsing_station_service' : 6 ,
1114
1149
}
1115
1150
1116
1151
def __init__ (self ):
1117
1152
pass
1118
1153
1154
+ @property
1155
+ def browsing_station_service (self ):
1156
+ if self ._p :
1157
+ return self ._p [- 1 ][self ._id ['browsing_station_service' ]]
1158
+ else :
1159
+ return False
1160
+
1161
+ @browsing_station_service .setter
1162
+ def browsing_station_service (self , value ):
1163
+ if self ._p :
1164
+ self ._p [- 1 ][self ._id ['browsing_station_service' ]] = value
1165
+
1119
1166
@property
1120
1167
def stations_file (self ):
1121
1168
if self ._p :
@@ -1157,7 +1204,7 @@ def selection(self):
1157
1204
if self ._p :
1158
1205
return self ._p [- 1 ][self ._id ['selection' ]]
1159
1206
else :
1160
- return ''
1207
+ return 0
1161
1208
1162
1209
@selection .setter
1163
1210
def selection (self , value ):
@@ -1169,13 +1216,25 @@ def startPos(self):
1169
1216
if self ._p :
1170
1217
return self ._p [- 1 ][self ._id ['startPos' ]]
1171
1218
else :
1172
- return ''
1219
+ return 0
1173
1220
1174
1221
@startPos .setter
1175
1222
def startPos (self , value ):
1176
1223
if self ._p :
1177
1224
self ._p [- 1 ][self ._id ['startPos' ]] = value
1178
1225
1226
+ @property
1227
+ def playing (self ):
1228
+ if self ._p :
1229
+ return self ._p [- 1 ][self ._id ['playing' ]]
1230
+ else :
1231
+ return - 1
1232
+
1233
+ @playing .setter
1234
+ def playing (self , value ):
1235
+ if self ._p :
1236
+ self ._p [- 1 ][self ._id ['playing' ]] = value
1237
+
1179
1238
def remove_duplicates (self ):
1180
1239
if len (self ._p ) > 1 :
1181
1240
val1 = self ._p [- 1 ][self ._id ['stations_filename_only' ]]
@@ -1189,7 +1248,9 @@ def remove_duplicates(self):
1189
1248
1190
1249
def add (self , stations_file = '' ,
1191
1250
stations_filename_only = '' ,
1192
- stations_filename_only_no_extension = '' ):
1251
+ stations_filename_only_no_extension = '' ,
1252
+ startPos = 0 , selection = 0 , playing = - 1 ,
1253
+ browsing_station_service = False ):
1193
1254
if len (self ._p ) > 1 and stations_file :
1194
1255
if self ._p [- 2 ][self ._id ['stations_file' ]] == stations_file :
1195
1256
if logger .isEnabledFor (logging .DEBUG ):
@@ -1198,7 +1259,8 @@ def add(self, stations_file='',
1198
1259
self ._p .append ([stations_file ,
1199
1260
stations_filename_only ,
1200
1261
stations_filename_only_no_extension ,
1201
- 0 , 0 ])
1262
+ startPos , selection , playing ,
1263
+ browsing_station_service ])
1202
1264
1203
1265
def get_member (self , member ):
1204
1266
if member in self ._id .keys ():
@@ -1208,13 +1270,22 @@ def get_member(self, member):
1208
1270
1209
1271
def pop (self ):
1210
1272
if len (self ._p ) > 1 :
1211
- self ._p .pop ()
1212
- return True
1273
+ return self ._p .pop ()
1213
1274
else :
1214
1275
if logger .isEnabledFor (logging .DEBUG ):
1215
1276
logger .debug ('Refusing to remove first entry' )
1216
- return False
1277
+ return self ._p [0 ]
1278
+
1279
+ def set (self , a_list ):
1280
+ if a_list :
1281
+ self ._p = a_list [:]
1282
+ else :
1283
+ raise ValueError ('playlist history cannot be empty' )
1217
1284
1218
1285
def reset (self ):
1219
1286
if self ._p :
1220
- iself ._p = self ._p [:1 ]
1287
+ self ._p = self ._p [:1 ]
1288
+
1289
+ def copy (self ):
1290
+ return self ._p [:]
1291
+
0 commit comments