~trb143/openlp/more_media

« back to all changes in this revision

Viewing changes to openlp/plugins/media/lib/mediaitem.py

  • Committer: Tim Bentley
  • Date: 2019-06-11 18:08:21 UTC
  • mfrom: (2876.1.2 openlp)
  • Revision ID: tim.bentley@gmail.com-20190611180821-m0viu2wi93p2o97k
Head

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
            item = self.list_view.currentItem()
174
174
            if item is None:
175
175
                return False
176
 
        filename = item.data(QtCore.Qt.UserRole)
 
176
        filename = str(item.data(QtCore.Qt.UserRole))
177
177
        # Special handling if the filename is a optical clip
178
178
        if filename.startswith('optical:'):
179
179
            (name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(filename)
259
259
        # TODO needs to be fixed as no idea why this fails
260
260
        # media.sort(key=lambda file_path: get_natural_key(file_path.name))
261
261
        for track in media:
262
 
            track_info = QtCore.QFileInfo(track)
 
262
            track_str = str(track)
 
263
            track_info = QtCore.QFileInfo(track_str)
263
264
            item_name = None
264
 
            if track.startswith('optical:'):
 
265
            if track_str.startswith('optical:'):
265
266
                # Handle optical based item
266
 
                (file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
 
267
                (file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track_str)
267
268
                item_name = QtWidgets.QListWidgetItem(clip_name)
268
269
                item_name.setIcon(UiIcons().optical)
269
270
                item_name.setData(QtCore.Qt.UserRole, track)
272
273
                                                                   end=format_milliseconds(end)))
273
274
            elif not os.path.exists(track):
274
275
                # File doesn't exist, mark as error.
275
 
                file_name = os.path.split(str(track))[1]
 
276
                file_name = os.path.split(track_str)[1]
276
277
                item_name = QtWidgets.QListWidgetItem(file_name)
277
278
                item_name.setIcon(UiIcons().error)
278
279
                item_name.setData(QtCore.Qt.UserRole, track)
279
 
                item_name.setToolTip(track)
 
280
                item_name.setToolTip(track_str)
280
281
            elif track_info.isFile():
281
282
                # Normal media file handling.
282
 
                file_name = os.path.split(str(track))[1]
 
283
                file_name = os.path.split(track_str)[1]
283
284
                item_name = QtWidgets.QListWidgetItem(file_name)
284
285
                search = file_name.split('.')[-1].lower()
285
 
                if '*.{text}'.format(text=search) in self.media_controller.audio_extensions_list:
 
286
                if search in AUDIO_EXT:
286
287
                    item_name.setIcon(UiIcons().audio)
287
288
                else:
288
289
                    item_name.setIcon(UiIcons().video)
289
290
                item_name.setData(QtCore.Qt.UserRole, track)
290
 
                item_name.setToolTip(track)
 
291
                item_name.setToolTip(track_str)
291
292
            if item_name:
292
293
                self.list_view.addItem(item_name)
293
294