Commit cdd67e47 authored by Duncan McNamara's avatar Duncan McNamara
Browse files

[WIP]

parent 31897358
Subproject commit d75a31a0c4fba59c7a671d5862bfa5bd69095a73
Subproject commit defa07d53dc264656da105803a3f71b85dba50ab
......@@ -533,6 +533,7 @@ Status MetadataAnalyzer::parseSubscription( IItem& item ) const
else
{
auto name = item.meta( IItem::Metadata::Title );
LOG_DEBUG("Subscription name: ", name);
if ( name.empty() == true )
name = utils::file::fileName( mrl );
auto t = m_ml->getConn()->newTransaction();
......@@ -561,6 +562,7 @@ Status MetadataAnalyzer::parseSubscription( IItem& item ) const
void MetadataAnalyzer::addSubscriptionElement( const IItem& item, int64_t subscriptionId,
std::string mrl, std::string title ) const
{
LOG_DEBUG("skbench: add subscription element: name: ", mrl);
auto t = m_ml->getConn()->newTransaction();
auto file = File::fromExternalMrl( m_ml, mrl );
if ( file == nullptr )
......@@ -583,7 +585,7 @@ void MetadataAnalyzer::addSubscriptionElement( const IItem& item, int64_t subscr
if ( ts != static_cast<time_t>( -1 ) )
media->setReleaseDate( ts );
}
}
}
auto files = media->files();
auto mainFileIt = std::find_if( cbegin( files ), cend( files ),
[]( const std::shared_ptr<IFile>& f ) {
......@@ -893,6 +895,7 @@ std::tuple<bool, bool> MetadataAnalyzer::refreshFile( IItem& item ) const
std::tuple<bool, bool> MetadataAnalyzer::refreshMedia( IItem& item ) const
{
LOG_DEBUG("skbench: ");
auto file = std::static_pointer_cast<File>( item.file() );
// If we restored this task, we already know the media. Otherwise, it's not
// loaded in the item yet.
......@@ -1072,6 +1075,7 @@ std::tuple<bool, bool> MetadataAnalyzer::refreshSubscription( IItem& item ) cons
Status MetadataAnalyzer::parseAudioFile( IItem& item, Cache& cache )
{
LOG_DEBUG("skbench: item: ", item.meta( IItem::Metadata::Title ));
auto genre = handleGenre( item );
auto artists = findOrCreateArtist( item );
if ( artists.first == nullptr && artists.second == nullptr )
......@@ -1524,10 +1528,13 @@ void MetadataAnalyzer::link( IItem& item, Album& album,
}
assert( albumArtist != nullptr );
LOG_DEBUG("skbench: media: ", media.title());
if ( mediaThumbnail != nullptr )
{
assignThumbnails( media, album, *albumArtist, newAlbum,
std::move( mediaThumbnail ) );
} else {
LOG_DEBUG("skbench: no thumbnail");
}
albumArtist->addMedia( media );
......@@ -1637,6 +1644,7 @@ void MetadataAnalyzer::assignThumbnails( Media& media, Album& album,
assert( thumbnail != nullptr );
assert( thumbnail->origin() == Thumbnail::Origin::Media ||
thumbnail->origin() == Thumbnail::Origin::CoverFile );
LOG_DEBUG("skbench: Media: ", media.title());
/* We need to assign a thumbnail to the media, album, and artist.
* The thumbnail we are assigning either comes from an embedded artwork, or
......
......@@ -81,7 +81,7 @@ Status VLCMetadataService::run( IItem& item )
#else
VLC::Media vlcMedia{ instance, mrl, VLC::Media::FromType::FromLocation };
#endif
vlcMedia.addOption( ":no-lua" );
// vlcMedia.addOption( ":no-lua" );
VLC::Media::ParsedStatus status;
bool done = false;
......@@ -158,6 +158,9 @@ Status VLCMetadataService::run( IItem& item )
}
if ( status == VLC::Media::ParsedStatus::Failed || status == VLC::Media::ParsedStatus::Timeout )
return Status::Fatal;
LOG_DEBUG( "item.filetype sub: ", item.fileType() == IFile::Type::Subscription);
LOG_DEBUG( "item.filetype sub: ", item.fileType() == IFile::Type::Playlist);
LOG_DEBUG( "item sub count: ", vlcMedia.subitems()->count());
if ( ( item.fileType() == IFile::Type::Playlist ||
item.fileType() == IFile::Type::Subscription ) &&
vlcMedia.subitems()->count() == 0 )
......@@ -168,10 +171,13 @@ Status VLCMetadataService::run( IItem& item )
" with no subitem: ", mrl );
return Status::Fatal;
}
auto artworkMrl = vlcMedia.meta( libvlc_meta_ArtworkURL );
LOG_DEBUG("skbench: artwork: ", artworkMrl);
#if LIBVLC_VERSION_INT < LIBVLC_VERSION(4, 0, 0, 0) && !defined(FORCE_ATTACHMENTS_API)
auto artworkMrl = vlcMedia.meta( libvlc_meta_ArtworkURL );
if ( artworkMrl.empty() == false )
{
LOG_DEBUG("skbench: Has artwork MRL");
if ( utils::url::schemeIs( "attachment://", artworkMrl ) == true )
{
LOG_WARN( "Artwork for ", mrl, " is an attachment. Falling back to playback" );
......@@ -182,6 +188,8 @@ Status VLCMetadataService::run( IItem& item )
}
item.addEmbeddedThumbnail( std::make_shared<VLCEmbeddedThumbnail3_0>(
utils::url::toLocalPath( vlcMedia.meta( libvlc_meta_ArtworkURL ) ) ) );
} else {
LOG_DEBUG("skbench: Empty artwork MRL");
}
#endif
mediaToItem( vlcMedia, item );
......@@ -221,6 +229,7 @@ void VLCMetadataService::stop()
void VLCMetadataService::mediaToItem( VLC::Media& media, IItem& item )
{
LOG_DEBUG("artwork MRL: ", media.meta( libvlc_meta_ArtworkURL ));
item.setMeta( IItem::Metadata::Title,
media.meta( libvlc_meta_Title ) );
item.setMeta( IItem::Metadata::ArtworkUrl,
......@@ -309,6 +318,7 @@ void VLCMetadataService::mediaToItem( VLC::Media& media, IItem& item )
auto vlcMedia = subItems->itemAtIndex( i );
assert( vlcMedia != nullptr );
auto mrl = vlcMedia->mrl();
LOG_DEBUG("skbench: media title: ", mrl);
mrl = utils::url::encode( utils::url::decode( mrl ) );
IItem& subItem = item.createLinkedItem( mrl,
IFile::Type::Main, i );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment