ShowEpisodeModel.swift 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*****************************************************************************
  2. * ShowEpisodeModel.swift
  3. *
  4. * Copyright © 2018 VLC authors and VideoLAN
  5. * Copyright © 2018 Videolabs
  6. *
  7. * Authors: Soomin Lee <bubu@mikan.io>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. class ShowEpisodeModel: MLBaseModel {
  12. typealias MLType = VLCMLMedia
  13. var updateView: (() -> Void)?
  14. var files = [VLCMLMedia]()
  15. var medialibrary: VLCMediaLibraryManager
  16. var indicatorName: String = NSLocalizedString("EPISODES", comment: "")
  17. required init(medialibrary: VLCMediaLibraryManager) {
  18. self.medialibrary = medialibrary
  19. medialibrary.addObserver(self)
  20. }
  21. func append(_ item: VLCMLMedia) {
  22. files.append(item)
  23. }
  24. func delete(_ items: [VLCMLObject]) {
  25. preconditionFailure("ShowEpisodeModel: Cannot delete showEpisode")
  26. }
  27. }
  28. extension ShowEpisodeModel: MediaLibraryObserver {
  29. func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddShowEpisodes showEpisodes: [VLCMLMedia]) {
  30. showEpisodes.forEach({ append($0) })
  31. updateView?()
  32. }
  33. }