Skip to content

Commit

Permalink
get file name from yt-dlp using raw mode instead of string mode and u…
Browse files Browse the repository at this point in the history
…se Qbytearray class to manage it
  • Loading branch information
mhogomchungu committed Feb 12, 2025
1 parent 7dda076 commit b65e2d5
Show file tree
Hide file tree
Showing 16 changed files with 1,497 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/basicdownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void basicdownloader::run( const basicdownloader::engine& eng,
m_parent( p ),m_engine( engine ),m_id( id ),m_getList( l )
{
}
void done( engines::ProcessExitState m,const QStringList& fileNames )
void done( engines::ProcessExitState m,const std::vector< QByteArray >& fileNames )
{
m_parent.m_ctx.TabManager().enableAll() ;

Expand Down
20 changes: 13 additions & 7 deletions src/batchdownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,10 @@ void batchdownloader::renameFile( int row )

if( !m.isEmpty() ){

m_table.setFileNames( row,{ m } ) ;
std::vector< QByteArray > s ;
s.emplace_back( m.toUtf8() ) ;

m_table.setFileNames( row,std::move( s ) ) ;
}
}
}
Expand Down Expand Up @@ -1887,7 +1890,7 @@ void batchdownloader::showThumbnail( const engines::engine& engine,
{
return utility::addData( e ) ;
}
void done( engines::ProcessExitState e,const QStringList& )
void done( engines::ProcessExitState e,const std::vector< QByteArray >& )
{
auto& a = m_parent ;
auto& b = m_engine ;
Expand Down Expand Up @@ -2245,7 +2248,7 @@ void batchdownloader::showList( batchdownloader::listType listType,
return false ;
}
}
void done( engines::ProcessExitState st,const QStringList& )
void done( engines::ProcessExitState st,const std::vector< QByteArray >& )
{
m_parent.m_ctx.TabManager().enableAll() ;

Expand Down Expand Up @@ -2548,7 +2551,8 @@ void batchdownloader::download( const engines::engine& engine,int init )
this->download( engine,indexes.move() ) ;
}

void batchdownloader::reportFinishedStatus( const reportFinished& f,const QStringList& fileNames )
void batchdownloader::reportFinishedStatus( const reportFinished& f,
const std::vector< QByteArray >& fileNames )
{
auto finishedStatus = f.finishedStatus() ;

Expand Down Expand Up @@ -2628,7 +2632,7 @@ void batchdownloader::downloadEntry( const engines::engine& eng,int index )
return true ;
}
}
void done( engines::ProcessExitState e,QStringList s )
void done( engines::ProcessExitState e,std::vector< QByteArray > s )
{
event ev( m_parent,m_engine,std::move( s ) ) ;
m_parent.m_ccmd.monitorForFinished( m_engine,m_index,e.move(),ev.move() ) ;
Expand Down Expand Up @@ -2656,7 +2660,7 @@ void batchdownloader::downloadEntry( const engines::engine& eng,int index )
class event
{
public:
event( batchdownloader& p,const engines::engine& engine,QStringList f ) :
event( batchdownloader& p,const engines::engine& engine,std::vector< QByteArray > f ) :
m_parent( p ),m_engine( engine ),m_fileNames( std::move( f ) )
{
}
Expand All @@ -2677,7 +2681,7 @@ void batchdownloader::downloadEntry( const engines::engine& eng,int index )
private:
batchdownloader& m_parent ;
const engines::engine& m_engine ;
QStringList m_fileNames ;
std::vector< QByteArray > m_fileNames ;
} ;

batchdownloader& m_parent ;
Expand All @@ -2693,6 +2697,8 @@ void batchdownloader::downloadEntry( const engines::engine& eng,int index )

auto updater = [ this,index ]( const QByteArray& e ){

qDebug() << "batch: " + e ;

emit this->addTextToUiSignal( e,index ) ;
} ;

Expand Down
8 changes: 4 additions & 4 deletions src/batchdownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ private
slots:
void addTextToUi( const QByteArray&,int ) ;
signals:
void reportFStatus( const reportFinished&,const QStringList& ) ;
void reportFStatus( const reportFinished&,const std::vector< QByteArray >& ) ;
void addItemUiSignal( ItemEntry ) ;
void addTextToUiSignal( const QByteArray&,int ) ;
private:
void showHideControls() ;
void networkData( const utility::networkReply& ) ;
void addItemUiSlot( ItemEntry ) ;
void reportFinishedStatus( const reportFinished&,const QStringList& ) ;
void reportFinishedStatus( const reportFinished&,const std::vector< QByteArray >& ) ;
enum class listType{ COMMENTS,SUBTITLES,MEDIA_OPTIONS } ;
void setDefaultEngineAndOptions( Items::entry& ) ;
void showList( batchdownloader::listType,const engines::engine&,const QString&,int ) ;
Expand Down Expand Up @@ -383,7 +383,7 @@ private
{
return m_localLogger.toLine() ;
}
const QStringList& fileNames() const
const std::vector< QByteArray >& fileNames() const
{
return m_localLogger.fileNames() ;
}
Expand Down Expand Up @@ -443,7 +443,7 @@ private

return data ;
}
const QStringList& fileNames() const
const std::vector< QByteArray >& fileNames() const
{
return m_logger->fileNames() ;
}
Expand Down
6 changes: 3 additions & 3 deletions src/engines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ QString engines::engine::baseEngine::deleteEngineBinFolder( const QString& e )
}
}

void engines::engine::baseEngine::runCommandOnDownloadedFile( const QStringList& fileNames )
void engines::engine::baseEngine::runCommandOnDownloadedFile( const std::vector< QByteArray >& fileNames )
{
auto df = m_settings.downloadFolder() + "/" ;

Expand Down Expand Up @@ -1532,7 +1532,7 @@ void engines::engine::baseEngine::openLocalFile( const engines::engine::baseEngi
{
auto e = [ & ](){

if( l.fileNames.isEmpty() ){
if( l.fileNames.size() ){

auto m = util::split( l.uiText,'\n',true ) ;

Expand All @@ -1543,7 +1543,7 @@ void engines::engine::baseEngine::openLocalFile( const engines::engine::baseEngi
return QString() ;
}
}else{
return l.fileNames.last() ;
return QString( l.fileNames.back() ) ;
}
}() ;

Expand Down
6 changes: 3 additions & 3 deletions src/engines.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ class engines

virtual QString deleteEngineBinFolder( const QString& ) ;

virtual void runCommandOnDownloadedFile( const QStringList& ) ;
virtual void runCommandOnDownloadedFile( const std::vector< QByteArray >& ) ;

virtual QString commandString( const engines::engine::exeArgs::cmd& ) ;

Expand All @@ -732,7 +732,7 @@ class engines
{
const QString& uiText ;
const QString& downloadFolder ;
const QStringList& fileNames ;
const std::vector< QByteArray >& fileNames ;
};

virtual void openLocalFile( const engines::engine::baseEngine::localFile& ) ;
Expand Down Expand Up @@ -986,7 +986,7 @@ class engines
{
return m_engine->commandString( cmd ) ;
}
void runCommandOnDownloadedFile( const QStringList& fileNames ) const
void runCommandOnDownloadedFile( const std::vector< QByteArray >& fileNames ) const
{
m_engine->runCommandOnDownloadedFile( fileNames ) ;
}
Expand Down
Loading

0 comments on commit b65e2d5

Please sign in to comment.