Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: (#1269) WMImageAPI λ―Έμ‚¬μš© μ½”λ“œ 제거 #1270

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading