Debian Codegraph @

src/core/podcasts/PodcastMeta.cpp

raw
1 /****************************************************************************************
2 * Copyright (c) 2007-2009 Bart Cerneels <[email protected]> *
3 * *
4 * This program is free software; you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free Software *
6 * Foundation; either version 2 of the License, or (at your option) any later *
7 * version. *
8 * *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY *
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU General Public License along with *
14 * this program. If not, see <http://www.gnu.org/licenses/>. *
15 ****************************************************************************************/
16
17 #include "core/podcasts/PodcastMeta.h"
18
19 using namespace Podcasts;
20
21 PodcastEpisode::PodcastEpisode()
22 : PodcastMetaCommon()
23 , Track()
24 , m_channel( nullptr )
25 , m_guid()
26 , m_mimeType()
27 , m_pubDate()
28 , m_duration( 0 )
29 , m_fileSize( 0 )
30 , m_sequenceNumber( 0 )
31 , m_isNew( true )
32 {
33 m_albumPtr = Meta::AlbumPtr( new PodcastAlbum( this ) );
34 m_artistPtr = Meta::ArtistPtr( new PodcastArtist( this ) );
35 m_composerPtr = Meta::ComposerPtr( new PodcastComposer( this ) );
36 m_genrePtr = Meta::GenrePtr( new PodcastGenre( this ) );
37 m_yearPtr = Meta::YearPtr( new PodcastYear( this ) );
38 }
39
40 PodcastEpisode::PodcastEpisode( const PodcastChannelPtr &channel )
41 : PodcastMetaCommon()
42 , Track()
43 , m_channel( channel )
44 , m_guid()
45 , m_mimeType()
46 , m_pubDate()
47 , m_duration( 0 )
48 , m_fileSize( 0 )
49 , m_sequenceNumber( 0 )
50 , m_isNew( true )
51 {
52 m_albumPtr = Meta::AlbumPtr( new PodcastAlbum( this ) );
53 m_artistPtr = Meta::ArtistPtr( new PodcastArtist( this ) );
54 m_composerPtr = Meta::ComposerPtr( new PodcastComposer( this ) );
55 m_genrePtr = Meta::GenrePtr( new PodcastGenre( this ) );
56 m_yearPtr = Meta::YearPtr( new PodcastYear( this ) );
57 }
58
59 PodcastEpisode::PodcastEpisode( const PodcastEpisodePtr &episode,
60 const PodcastChannelPtr &channel )
61 : m_channel( channel )
62 {
63 m_author = episode->author();
64 m_description = episode->description();
65 m_duration = episode->duration();
66 m_fileSize = episode->filesize();
67 m_guid = episode->guid();
68 m_isNew = episode->isNew();
69 m_keywords = episode->keywords();
70 m_localUrl = episode->localUrl();
71 m_mimeType = episode->mimeType();
72 m_title = episode->title();
73 m_pubDate = episode->pubDate();
74 m_sequenceNumber = episode->sequenceNumber();
75 m_subtitle = episode->subtitle();
76 m_summary = episode->summary();
77 m_url = QUrl::fromUserInput(episode->uidUrl());
78 }
79
80 QString
81 PodcastEpisode::notPlayableReason() const
82 {
83 if( m_localUrl.isEmpty() )
84 return networkNotPlayableReason();
85 else
86 return localFileNotPlayableReason( m_localUrl.toLocalFile() );
87 }
88
89 bool
90 PodcastEpisode::operator==( const Meta::Track &track ) const
91 {
92
93 return (
94 ( this->uidUrl() == track.uidUrl() ) &&
95 ( this->length() == track.length() ) &&
96 ( this->prettyName() == track.prettyName() ) &&
97 ( this->bitrate() == track.bitrate() ) &&
98 ( this->bpm() == track.bpm() )
99
100 );
101 }
102
103 PodcastChannel::PodcastChannel( const PodcastChannelPtr &channel )
104 {
105 m_author = channel->author();
106 m_autoScan = channel->autoScan();
107 m_copyright = channel->copyright();
108 m_description = channel->description();
109 m_directory = channel->saveLocation();
110 m_episodes = channel->episodes();
111 m_fetchType = channel->fetchType();
112 m_imageUrl = channel->m_imageUrl;
113 m_keywords = channel->keywords();
114 m_labels = channel->labels();
115 m_purge = channel->hasPurge();
116 m_purgeCount = channel->purgeCount();
117 m_subscribeDate = channel->subscribeDate();
118 m_subtitle = channel->subtitle();
119 m_summary = channel->summary();
120 m_title = channel->title();
121 m_url = channel->url();
122 m_webLink = channel->webLink();
123
124 for( PodcastEpisodePtr episode : channel->episodes() )
125 {
126 m_episodes << PodcastEpisodePtr(
127 new PodcastEpisode( episode, PodcastChannelPtr( this ) ) );
128 }
129 }
130
131 Meta::TrackList
132 PodcastChannel::tracks()
133 {
134 Meta::TrackList tracks;
135 for( Podcasts::PodcastEpisodePtr episode : episodes() )
136 tracks << Meta::TrackPtr::dynamicCast( episode );
137 return tracks;
138 }
139
140 void
141 PodcastChannel::addTrack( const Meta::TrackPtr &track, int position )
142 {
143 Q_UNUSED( position );
144 addEpisode( PodcastEpisodePtr::dynamicCast( track ) );
145 }
146
147 Podcasts::PodcastEpisodePtr
148 PodcastChannel::addEpisode( const PodcastEpisodePtr &episode )
149 {
150 if( !episode.isNull() )
151 m_episodes << episode;
152 return episode;
153 }