<commit_before>//
//  HLSion.swift
//  HLSion
//
//  Created by hyde on 2016/11/12.
//  Copyright © 2016年 r-plus. All rights reserved.
//

import Foundation
import AVFoundation

public typealias ProgressParameter = (Double) -> Void
public typealias FinishParameter = (String) -> Void

public class HLSion {
    
    public enum State: String {
        case notDownloaded
        case downloading
        case downloaded
    }
    
    // MARK: Properties
    
    /// Identifier name.
    public let name: String
    /// Target AVURLAsset that have HLS URL.
    public let urlAsset: AVURLAsset
    /// Download state.
    public var state: State {
        if SessionManager.shared.assetExists(forName: name) {
            return .downloaded
        }<commit_msg>Add `localUrl` property for offline playback.<commit_after>//
//  HLSion.swift
//  HLSion
//
//  Created by hyde on 2016/11/12.
//  Copyright © 2016年 r-plus. All rights reserved.
//

import Foundation
import AVFoundation

public typealias ProgressParameter = (Double) -> Void
public typealias FinishParameter = (String) -> Void

public class HLSion {
    
    public enum State: String {
        case notDownloaded
        case downloading
        case downloaded
    }
    
    // MARK: Properties
    
    /// Identifier name.
    public let name: String
    /// Target AVURLAsset that have HLS URL.
    public let urlAsset: AVURLAsset
    /// Local url path that saved for offline playback. return nil if not downloaded.
    public var localUrl: URL? {
        guard let relativePath = AssetStore.path(forName: name) else { return nil }
        return SessionManager.shared.homeDirectoryURL.appendingPathComponent(relativePath)
    }
    /// Download state.
    public var state: State {
        if SessionManager.shared.assetExists(forName: name) {
            return .downloaded
        }
{'fraction_non_alphanumeric': 0.08409703504043127, 'fraction_numerical': 0.01293800539083558, 'mean_word_length': 2.33213644524237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '767753', 'n_tokens_mistral': 544, 'n_tokens_neox': 512, 'n_words': 174}