File indexing completed on 2024-05-19 04:49:30
0001 /**************************************************************************************** 0002 * Copyright (c) 2007-2009 Bart Cerneels <bart.cerneels@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "core/podcasts/PodcastMeta.h" 0018 0019 using namespace Podcasts; 0020 0021 PodcastEpisode::PodcastEpisode() 0022 : PodcastMetaCommon() 0023 , Track() 0024 , m_channel( nullptr ) 0025 , m_guid() 0026 , m_mimeType() 0027 , m_pubDate() 0028 , m_duration( 0 ) 0029 , m_fileSize( 0 ) 0030 , m_sequenceNumber( 0 ) 0031 , m_isNew( true ) 0032 { 0033 m_albumPtr = Meta::AlbumPtr( new PodcastAlbum( this ) ); 0034 m_artistPtr = Meta::ArtistPtr( new PodcastArtist( this ) ); 0035 m_composerPtr = Meta::ComposerPtr( new PodcastComposer( this ) ); 0036 m_genrePtr = Meta::GenrePtr( new PodcastGenre( this ) ); 0037 m_yearPtr = Meta::YearPtr( new PodcastYear( this ) ); 0038 } 0039 0040 PodcastEpisode::PodcastEpisode( const PodcastChannelPtr &channel ) 0041 : PodcastMetaCommon() 0042 , Track() 0043 , m_channel( channel ) 0044 , m_guid() 0045 , m_mimeType() 0046 , m_pubDate() 0047 , m_duration( 0 ) 0048 , m_fileSize( 0 ) 0049 , m_sequenceNumber( 0 ) 0050 , m_isNew( true ) 0051 { 0052 m_albumPtr = Meta::AlbumPtr( new PodcastAlbum( this ) ); 0053 m_artistPtr = Meta::ArtistPtr( new PodcastArtist( this ) ); 0054 m_composerPtr = Meta::ComposerPtr( new PodcastComposer( this ) ); 0055 m_genrePtr = Meta::GenrePtr( new PodcastGenre( this ) ); 0056 m_yearPtr = Meta::YearPtr( new PodcastYear( this ) ); 0057 } 0058 0059 PodcastEpisode::PodcastEpisode( const PodcastEpisodePtr &episode, 0060 const PodcastChannelPtr &channel ) 0061 : m_channel( channel ) 0062 { 0063 m_author = episode->author(); 0064 m_description = episode->description(); 0065 m_duration = episode->duration(); 0066 m_fileSize = episode->filesize(); 0067 m_guid = episode->guid(); 0068 m_isNew = episode->isNew(); 0069 m_keywords = episode->keywords(); 0070 m_localUrl = episode->localUrl(); 0071 m_mimeType = episode->mimeType(); 0072 m_title = episode->title(); 0073 m_pubDate = episode->pubDate(); 0074 m_sequenceNumber = episode->sequenceNumber(); 0075 m_subtitle = episode->subtitle(); 0076 m_summary = episode->summary(); 0077 m_url = QUrl::fromUserInput(episode->uidUrl()); 0078 } 0079 0080 QString 0081 PodcastEpisode::notPlayableReason() const 0082 { 0083 if( m_localUrl.isEmpty() ) 0084 return networkNotPlayableReason(); 0085 else 0086 return localFileNotPlayableReason( m_localUrl.toLocalFile() ); 0087 } 0088 0089 bool 0090 PodcastEpisode::operator==( const Meta::Track &track ) const 0091 { 0092 0093 return ( 0094 ( this->uidUrl() == track.uidUrl() ) && 0095 ( this->length() == track.length() ) && 0096 ( this->prettyName() == track.prettyName() ) && 0097 ( this->bitrate() == track.bitrate() ) && 0098 ( this->bpm() == track.bpm() ) 0099 0100 ); 0101 } 0102 0103 PodcastChannel::PodcastChannel( const PodcastChannelPtr &channel ) 0104 { 0105 m_author = channel->author(); 0106 m_autoScan = channel->autoScan(); 0107 m_copyright = channel->copyright(); 0108 m_description = channel->description(); 0109 m_directory = channel->saveLocation(); 0110 m_episodes = channel->episodes(); 0111 m_fetchType = channel->fetchType(); 0112 m_imageUrl = channel->m_imageUrl; 0113 m_keywords = channel->keywords(); 0114 m_labels = channel->labels(); 0115 m_purge = channel->hasPurge(); 0116 m_purgeCount = channel->purgeCount(); 0117 m_subscribeDate = channel->subscribeDate(); 0118 m_subtitle = channel->subtitle(); 0119 m_summary = channel->summary(); 0120 m_title = channel->title(); 0121 m_url = channel->url(); 0122 m_webLink = channel->webLink(); 0123 0124 foreach( PodcastEpisodePtr episode, channel->episodes() ) 0125 { 0126 m_episodes << PodcastEpisodePtr( 0127 new PodcastEpisode( episode, PodcastChannelPtr( this ) ) ); 0128 } 0129 } 0130 0131 Meta::TrackList 0132 PodcastChannel::tracks() 0133 { 0134 Meta::TrackList tracks; 0135 foreach( Podcasts::PodcastEpisodePtr episode, episodes() ) 0136 tracks << Meta::TrackPtr::dynamicCast( episode ); 0137 return tracks; 0138 } 0139 0140 void 0141 PodcastChannel::addTrack( const Meta::TrackPtr &track, int position ) 0142 { 0143 Q_UNUSED( position ); 0144 addEpisode( PodcastEpisodePtr::dynamicCast( track ) ); 0145 } 0146 0147 Podcasts::PodcastEpisodePtr 0148 PodcastChannel::addEpisode( const PodcastEpisodePtr &episode ) 0149 { 0150 if( !episode.isNull() ) 0151 m_episodes << episode; 0152 return episode; 0153 }