From 93e08ef5145d004c4ccc7c17e5da69c9220647ff Mon Sep 17 00:00:00 2001 From: CappielloAntonio Date: Sat, 5 Feb 2022 18:34:21 +0100 Subject: [PATCH] Prepared subsonic model to accept podcast channels and episodes --- .../play/subsonic/models/NewestPodcasts.java | 29 +- .../play/subsonic/models/PodcastChannel.java | 140 +----- .../play/subsonic/models/PodcastEpisode.java | 397 +++++++++++++++--- .../play/subsonic/models/PodcastStatus.java | 34 +- .../play/subsonic/models/Podcasts.java | 29 +- .../subsonic/models/SubsonicResponse.java | 1 + 6 files changed, 385 insertions(+), 245 deletions(-) diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/models/NewestPodcasts.java b/app/src/main/java/com/cappielloantonio/play/subsonic/models/NewestPodcasts.java index 47f82216..dd0f88e0 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/models/NewestPodcasts.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/models/NewestPodcasts.java @@ -1,35 +1,24 @@ package com.cappielloantonio.play.subsonic.models; +import com.tickaroo.tikxml.annotation.Element; +import com.tickaroo.tikxml.annotation.Xml; + import java.util.ArrayList; import java.util.List; +@Xml public class NewestPodcasts { + @Element(name = "episode") protected List episodes; - /** - * Gets the value of the episodes property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the episodes property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getEpisodes().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link PodcastEpisode } - */ public List getEpisodes() { if (episodes == null) { episodes = new ArrayList<>(); } return this.episodes; } + + public void setEpisodes(List episodes) { + this.episodes = episodes; + } } diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastChannel.java b/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastChannel.java index 6af71073..fbc9967e 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastChannel.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastChannel.java @@ -1,39 +1,33 @@ package com.cappielloantonio.play.subsonic.models; +import com.tickaroo.tikxml.annotation.Attribute; +import com.tickaroo.tikxml.annotation.Element; +import com.tickaroo.tikxml.annotation.Xml; + import java.util.ArrayList; import java.util.List; +@Xml public class PodcastChannel { + @Element(name = "episode") protected List episodes; + @Attribute protected String id; + @Attribute protected String url; + @Attribute protected String title; + @Attribute protected String description; + @Attribute protected String coverArtId; + @Attribute protected String originalImageUrl; - protected PodcastStatus status; + @Attribute + protected String status; + @Attribute protected String errorMessage; - /** - * Gets the value of the episodes property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the episodes property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getEpisodes().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link PodcastEpisode } - */ public List getEpisodes() { if (episodes == null) { episodes = new ArrayList<>(); @@ -41,162 +35,70 @@ public class PodcastChannel { return this.episodes; } - /** - * Gets the value of the id property. - * - * @return possible object is - * {@link String } - */ + public void setEpisodes(List episodes) { + this.episodes = episodes; + } + public String getId() { return id; } - /** - * Sets the value of the id property. - * - * @param value allowed object is - * {@link String } - */ public void setId(String value) { this.id = value; } - /** - * Gets the value of the url property. - * - * @return possible object is - * {@link String } - */ public String getUrl() { return url; } - /** - * Sets the value of the url property. - * - * @param value allowed object is - * {@link String } - */ public void setUrl(String value) { this.url = value; } - /** - * Gets the value of the title property. - * - * @return possible object is - * {@link String } - */ public String getTitle() { return title; } - /** - * Sets the value of the title property. - * - * @param value allowed object is - * {@link String } - */ public void setTitle(String value) { this.title = value; } - /** - * Gets the value of the description property. - * - * @return possible object is - * {@link String } - */ public String getDescription() { return description; } - /** - * Sets the value of the description property. - * - * @param value allowed object is - * {@link String } - */ public void setDescription(String value) { this.description = value; } - /** - * Gets the value of the coverArtId property. - * - * @return possible object is - * {@link String } - */ public String getCoverArtId() { return coverArtId; } - /** - * Sets the value of the coverArtId property. - * - * @param value allowed object is - * {@link String } - */ public void setCoverArtId(String value) { this.coverArtId = value; } - /** - * Gets the value of the originalImageUrl property. - * - * @return possible object is - * {@link String } - */ public String getOriginalImageUrl() { return originalImageUrl; } - /** - * Sets the value of the originalImageUrl property. - * - * @param value allowed object is - * {@link String } - */ public void setOriginalImageUrl(String value) { this.originalImageUrl = value; } - /** - * Gets the value of the status property. - * - * @return possible object is - * {@link PodcastStatus } - */ - public PodcastStatus getStatus() { + public String getStatus() { return status; } - /** - * Sets the value of the status property. - * - * @param value allowed object is - * {@link PodcastStatus } - */ - public void setStatus(PodcastStatus value) { + public void setStatus(String value) { this.status = value; } - /** - * Gets the value of the errorMessage property. - * - * @return possible object is - * {@link String } - */ public String getErrorMessage() { return errorMessage; } - /** - * Sets the value of the errorMessage property. - * - * @param value allowed object is - * {@link String } - */ public void setErrorMessage(String value) { this.errorMessage = value; } diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastEpisode.java b/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastEpisode.java index b2ea2114..c926cf78 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastEpisode.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastEpisode.java @@ -1,111 +1,374 @@ package com.cappielloantonio.play.subsonic.models; +import com.tickaroo.tikxml.annotation.Attribute; +import com.tickaroo.tikxml.annotation.Element; +import com.tickaroo.tikxml.annotation.Xml; +import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter; + import java.time.LocalDateTime; +import java.util.Date; -public class PodcastEpisode extends Child { +@Xml +public class PodcastEpisode { + @Attribute + protected String id; + @Attribute(name = "parent") + protected String parentId; + @Attribute(name = "isDir") + protected boolean dir; + @Attribute + protected String title; + @Attribute + protected String album; + @Attribute + protected String artist; + @Attribute + protected Integer track; + @Attribute + protected Integer year; + @Attribute(name = "genre") + protected String genre; + @Attribute(name = "coverArt") + protected String coverArtId; + @Attribute + protected Long size; + @Attribute + protected String contentType; + @Attribute + protected String suffix; + @Attribute + protected String transcodedContentType; + @Attribute + protected String transcodedSuffix; + @Attribute + protected Integer duration; + @Attribute + protected Integer bitRate; + @Attribute + protected String path; + @Attribute(name = "isVideo") + protected Boolean video; + @Attribute + protected Integer userRating; + @Attribute + protected Double averageRating; + @Attribute + protected Long playCount; + @Attribute + protected Integer discNumber; + @Attribute(converter = DateRfc3339TypeConverter.class) + protected Date created; + @Attribute(converter = DateRfc3339TypeConverter.class) + protected Date starred; + @Attribute + protected String albumId; + @Attribute + protected String artistId; + @Attribute + protected String type; + @Attribute + protected Long bookmarkPosition; + @Attribute + protected Integer originalWidth; + @Attribute + protected Integer originalHeight; + + @Attribute protected String streamId; + @Attribute protected String channelId; + @Attribute protected String description; - protected PodcastStatus status; - protected LocalDateTime publishDate; + @Attribute + protected String status; + @Attribute(converter = DateRfc3339TypeConverter.class) + protected Date publishDate; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public boolean isDir() { + return dir; + } + + public void setDir(boolean dir) { + this.dir = dir; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAlbum() { + return album; + } + + public void setAlbum(String album) { + this.album = album; + } + + public String getArtist() { + return artist; + } + + public void setArtist(String artist) { + this.artist = artist; + } + + public Integer getTrack() { + return track; + } + + public void setTrack(Integer track) { + this.track = track; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } + + public String getGenre() { + return genre; + } + + public void setGenre(String genre) { + this.genre = genre; + } + + public String getCoverArtId() { + return coverArtId; + } + + public void setCoverArtId(String coverArtId) { + this.coverArtId = coverArtId; + } + + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + public String getTranscodedContentType() { + return transcodedContentType; + } + + public void setTranscodedContentType(String transcodedContentType) { + this.transcodedContentType = transcodedContentType; + } + + public String getTranscodedSuffix() { + return transcodedSuffix; + } + + public void setTranscodedSuffix(String transcodedSuffix) { + this.transcodedSuffix = transcodedSuffix; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + + public Integer getBitRate() { + return bitRate; + } + + public void setBitRate(Integer bitRate) { + this.bitRate = bitRate; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public Boolean getVideo() { + return video; + } + + public void setVideo(Boolean video) { + this.video = video; + } + + public Integer getUserRating() { + return userRating; + } + + public void setUserRating(Integer userRating) { + this.userRating = userRating; + } + + public Double getAverageRating() { + return averageRating; + } + + public void setAverageRating(Double averageRating) { + this.averageRating = averageRating; + } + + public Long getPlayCount() { + return playCount; + } + + public void setPlayCount(Long playCount) { + this.playCount = playCount; + } + + public Integer getDiscNumber() { + return discNumber; + } + + public void setDiscNumber(Integer discNumber) { + this.discNumber = discNumber; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getStarred() { + return starred; + } + + public void setStarred(Date starred) { + this.starred = starred; + } + + public String getAlbumId() { + return albumId; + } + + public void setAlbumId(String albumId) { + this.albumId = albumId; + } + + public String getArtistId() { + return artistId; + } + + public void setArtistId(String artistId) { + this.artistId = artistId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Long getBookmarkPosition() { + return bookmarkPosition; + } + + public void setBookmarkPosition(Long bookmarkPosition) { + this.bookmarkPosition = bookmarkPosition; + } + + public Integer getOriginalWidth() { + return originalWidth; + } + + public void setOriginalWidth(Integer originalWidth) { + this.originalWidth = originalWidth; + } + + public Integer getOriginalHeight() { + return originalHeight; + } + + public void setOriginalHeight(Integer originalHeight) { + this.originalHeight = originalHeight; + } - /** - * Gets the value of the streamId property. - * - * @return possible object is - * {@link String } - */ public String getStreamId() { return streamId; } - /** - * Sets the value of the streamId property. - * - * @param value allowed object is - * {@link String } - */ public void setStreamId(String value) { this.streamId = value; } - /** - * Gets the value of the channelId property. - * - * @return possible object is - * {@link String } - */ public String getChannelId() { return channelId; } - /** - * Sets the value of the channelId property. - * - * @param value allowed object is - * {@link String } - */ public void setChannelId(String value) { this.channelId = value; } - /** - * Gets the value of the description property. - * - * @return possible object is - * {@link String } - */ public String getDescription() { return description; } - /** - * Sets the value of the description property. - * - * @param value allowed object is - * {@link String } - */ public void setDescription(String value) { this.description = value; } - /** - * Gets the value of the status property. - * - * @return possible object is - * {@link PodcastStatus } - */ - public PodcastStatus getStatus() { + public String getStatus() { return status; } - /** - * Sets the value of the status property. - * - * @param value allowed object is - * {@link PodcastStatus } - */ - public void setStatus(PodcastStatus value) { + public void setStatus(String value) { this.status = value; } - /** - * Gets the value of the publishDate property. - * - * @return possible object is - * {@link String } - */ - public LocalDateTime getPublishDate() { + public Date getPublishDate() { return publishDate; } - /** - * Sets the value of the publishDate property. - * - * @param value allowed object is - * {@link String } - */ - public void setPublishDate(LocalDateTime value) { + public void setPublishDate(Date value) { this.publishDate = value; } } diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastStatus.java b/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastStatus.java index f7923827..1d7db49c 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastStatus.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/models/PodcastStatus.java @@ -1,29 +1,25 @@ package com.cappielloantonio.play.subsonic.models; -public enum PodcastStatus { - NEW("new"), - DOWNLOADING("downloading"), - COMPLETED("completed"), - ERROR("error"), - DELETED("deleted"), - SKIPPED("skipped"); +import com.tickaroo.tikxml.annotation.Attribute; +import com.tickaroo.tikxml.annotation.Xml; - private final String value; +@Xml +public class PodcastStatus { + public static String NEW = "new"; + public static String DOWNLOADING = "downloading"; + public static String COMPLETED = "completed"; + public static String ERROR = "error"; + public static String DELETED = "deleted"; + public static String SKIPPED = "skipped"; - PodcastStatus(String v) { - value = v; - } + @Attribute + private String value; - public String value() { + public String getValue() { return value; } - public static PodcastStatus fromValue(String v) { - for (PodcastStatus c : PodcastStatus.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); + public void setValue(String value) { + this.value = value; } } diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/models/Podcasts.java b/app/src/main/java/com/cappielloantonio/play/subsonic/models/Podcasts.java index cf9a67a3..5ec3d755 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/models/Podcasts.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/models/Podcasts.java @@ -1,35 +1,24 @@ package com.cappielloantonio.play.subsonic.models; +import com.tickaroo.tikxml.annotation.Element; +import com.tickaroo.tikxml.annotation.Xml; + import java.util.ArrayList; import java.util.List; +@Xml public class Podcasts { + @Element(name = "channel") protected List channels; - /** - * Gets the value of the channels property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the channels property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getChannels().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link PodcastChannel } - */ public List getChannels() { if (channels == null) { channels = new ArrayList<>(); } return this.channels; } + + public void setChannels(List channels) { + this.channels = channels; + } } diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java b/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java index d9916731..ba43f97b 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/models/SubsonicResponse.java @@ -28,6 +28,7 @@ public class SubsonicResponse { private PlayQueue playQueue; private Bookmarks bookmarks; private InternetRadioStations internetRadioStations; + @Element(name = "newestPodcasts") private NewestPodcasts newestPodcasts; private Podcasts podcasts; @Element(name = "lyrics")