Skip to content

Commit

Permalink
Renamed "JSONPodcastsIndex" to "PodcastsIndex"
Browse files Browse the repository at this point in the history
There was no need to have the JSON in the coder name.
  • Loading branch information
dagronf committed Jul 30, 2024
1 parent 9ba8fa3 commit b1a6555
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ A Swift package for reading/writing some common subtitle formats.

## Available coders

| Format | Coder | File extension |
|:---------------------|:------------------------------------|:----------------|
| SBV (SubViewer) | `Subtitles.Coder.SBV` | `.sbv` |
| SUB (MicroDVD)* | `Subtitles.Coder.SUB` | `.sub` |
| SRT (SubRip) | `Subtitles.Coder.SRT` | `.srt` |
| VTT (WebVTT) | `Subtitles.Coder.VTT` | `.vtt` |
| CSV | `Subtitles.Coder.CSV` | `.csv` |
| JSON (Podcast Index) | `Subtitles.Coder.JSONPodcastsIndex` | `.json` |
| Format | Coder | File extension |
|:----------------------|:---------------------------------|:----------------|
| SBV (SubViewer) | `Subtitles.Coder.SBV` | `.sbv` |
| SUB (MicroDVD)* | `Subtitles.Coder.SUB` | `.sub` |
| SRT (SubRip) | `Subtitles.Coder.SRT` | `.srt` |
| VTT (WebVTT) | `Subtitles.Coder.VTT` | `.vtt` |
| CSV | `Subtitles.Coder.CSV` | `.csv` |
| JSON (Podcasts Index) | `Subtitles.Coder.PodcastsIndex` | `.json` |

* Read-only

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSubtitles/Subtitles+codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ extension Subtitles.Coder {
Subtitles.Coder.JSON.self,
Subtitles.Coder.SUB.self,
Subtitles.Coder.CSV.self,
Subtitles.Coder.JSONPodcastIndex.self,
Subtitles.Coder.PodcastsIndex.self,
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import Foundation

extension Subtitles.Coder {
/// A [Podcast Index Transcript](https://github.com/Podcastindex-org/podcast-namespace/blob/main/transcripts/transcripts.md#json) encoder/decoder
public struct JSONPodcastIndex: SubtitlesCodable, SubtitlesTextCodable, Codable {
public struct PodcastsIndex: SubtitlesCodable, SubtitlesTextCodable, Codable {
public static var extn: String { "json" }
public static func Create() -> Self { JSONPodcastIndex() }
public static func Create() -> Self { PodcastsIndex() }
public init() {
version = "1.0.0"
segments = []
Expand Down Expand Up @@ -60,7 +60,7 @@ extension Subtitles.Coder {
}
}

public extension Subtitles.Coder.JSONPodcastIndex {
public extension Subtitles.Coder.PodcastsIndex {
/// Encode subtitles as Data
/// - Parameters:
/// - subtitles: The subtitles to encode
Expand All @@ -77,7 +77,7 @@ public extension Subtitles.Coder.JSONPodcastIndex {
)
segments.append(segment)
}
return try JSONEncoder().encode(Subtitles.Coder.JSONPodcastIndex(version: "1.0.0", segments: segments))
return try JSONEncoder().encode(Subtitles.Coder.PodcastsIndex(version: "1.0.0", segments: segments))
}

/// Encode subtitles as a String
Expand All @@ -93,14 +93,14 @@ public extension Subtitles.Coder.JSONPodcastIndex {
}
}

public extension Subtitles.Coder.JSONPodcastIndex {
public extension Subtitles.Coder.PodcastsIndex {
/// Decode subtitles from json data
/// - Parameters:
/// - data: The data to decode
/// - encoding: The string encoding for the data content
/// - Returns: Subtitles
func decode(_ data: Data, encoding: String.Encoding) throws -> Subtitles {
let value = try JSONDecoder().decode(Subtitles.Coder.JSONPodcastIndex.self, from: data)
let value = try JSONDecoder().decode(Subtitles.Coder.PodcastsIndex.self, from: data)
var cues = [Subtitles.Cue]()
for segment in value.segments {
let cue = Subtitles.Cue(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest
@testable import SwiftSubtitles

final class JSONPodcastIndexTests: XCTestCase {
final class PodcastIndexTests: XCTestCase {
func testExample() throws {
let fileURL = try resourceURL(forResource: "sample", withExtension: "json")
let subtitles = try Subtitles(fileURL: fileURL, encoding: .utf8)
Expand Down Expand Up @@ -42,7 +42,7 @@ final class JSONPodcastIndexTests: XCTestCase {
let speakers = subtitles.uniqueSpeakers
XCTAssertEqual(Set(["Darth Vader", "Luke"]), speakers)

let enc = Subtitles.Coder.JSONPodcastIndex()
let enc = Subtitles.Coder.PodcastsIndex()
let encodedData = try enc.encode(subtitles: subtitles, encoding: .utf8)

let decoded = try enc.decode(encodedData, encoding: .utf8)
Expand Down

0 comments on commit b1a6555

Please sign in to comment.