Skip to content

Commit

Permalink
Merge pull request #1270 from wakmusic/1269-remove-unuse-wmimage-api
Browse files Browse the repository at this point in the history
  • Loading branch information
KangTaeHoon authored Aug 31, 2024
2 parents b95ef95 + df0d535 commit 5abcbd8
Showing 1 changed file with 2 additions and 50 deletions.
52 changes: 2 additions & 50 deletions Projects/Modules/Utility/Sources/API/WMImageAPI.swift
Original file line number Diff line number Diff line change
@@ -1,83 +1,35 @@
//
// WMImageAPI.swift
// Utility
//
// Created by KTH on 2023/02/10.
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import Foundation

public enum WMImageAPI {
case fetchNewsThumbnail(time: String)
case fetchArtistWithRound(id: String, version: Int)
case fetchArtistWithSquare(id: String, version: Int)
case fetchPlayList(id: String, version: Int)
case fetchRecommendPlaylistWithRound(id: String, version: Int)
case fetchRecommendPlaylistWithSquare(id: String, version: Int)
case fetchYoutubeThumbnail(id: String)
case fetchYoutubeThumbnailHD(id: String)
case fetchNotice(id: String)
}

public extension WMImageAPI {
var baseURLString: String {
return BASE_IMAGE_URL()
}

var youtubeBaseURLString: String {
return "https://i.ytimg.com"
}

var path: String {
switch self {
case let .fetchNewsThumbnail(time):
return WMDOMAIN_IMAGE_NEWS() + "/\(time).png"

case let .fetchArtistWithRound(id, version):
return WMDOMAIN_IMAGE_ARTIST_ROUND() + "/\(id).png?v=\(version)"

case let .fetchArtistWithSquare(id, version):
return WMDOMAIN_IMAGE_ARTIST_SQUARE() + "/\(id).png?v=\(version)"

case let .fetchPlayList(id, version):
return WMDOMAIN_IMAGE_PLAYLIST() + "/\(id).png?v=\(version)"

case let .fetchRecommendPlaylistWithSquare(id, version):
return WMDOMAIN_IMAGE_RECOMMEND_PLAYLIST_SQUARE() + "/\(id).png?v=\(version)"

case let .fetchRecommendPlaylistWithRound(id, version):
return WMDOMAIN_IMAGE_RECOMMEND_PLAYLIST_ROUND() + "/\(id).png?v=\(version)"

case let .fetchYoutubeThumbnail(id):
return "vi/\(id)/mqdefault.jpg"

case let .fetchYoutubeThumbnailHD(id):
return "vi/\(id)/maxresdefault.jpg"

case let .fetchNotice(id):
return WMDOMAIN_IMAGE_NOTICE() + "/\(id)"
}
}

var toString: String {
switch self {
case .fetchYoutubeThumbnail:
return youtubeBaseURLString + "/" + path
case .fetchYoutubeThumbnailHD:
return youtubeBaseURLString + "/" + path
default:
case .fetchYoutubeThumbnail, .fetchYoutubeThumbnailHD:
return baseURLString + "/" + path
}
}

var toURL: URL? {
switch self {
case .fetchYoutubeThumbnail:
return URL(string: youtubeBaseURLString + "/" + path)
case .fetchYoutubeThumbnailHD:
return URL(string: youtubeBaseURLString + "/" + path)
default:
case .fetchYoutubeThumbnail, .fetchYoutubeThumbnailHD:
return URL(string: baseURLString + "/" + path)
}
}
Expand Down

0 comments on commit 5abcbd8

Please sign in to comment.