Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed May 20, 2024
1 parent 7f9f6e7 commit d53ad50
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
9 changes: 2 additions & 7 deletions src/engines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,9 @@ static QProcessEnvironment _getEnvPaths( const engines::enginePaths& paths,setti

auto m = utility::OSXApplicationDirPath() ;

const auto e = m ;
auto e = utility::OSX3rdPartyDirPath() ;

for( const auto& it : _dirEntries( e ) ){

m += separator + e + "/" + it ;
}

s += separator + m ;
s += separator + m + separator + e ;
}

for( const auto& it : _dirEntries( basePath ) ){
Expand Down
25 changes: 16 additions & 9 deletions src/engines/yt-dlp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ video:9475kB audio:7554kB subtitle:0kB other streams:0kB global headers:0kB muxi
[download] 100% of 17.13MiB in 00:00:12 at 1.40MiB/s)R" ;
}

static QString _OSXBinaryName()
{
return "yt-dlp_macos" ;
}

static QString _Windows32BitBinaryName()
{
return "yt-dlp_x86.exe" ;
Expand Down Expand Up @@ -156,11 +161,10 @@ void yt_dlp::checkIfBinaryExist( const QString& runTimeBinPath,const QString& th

}else if( utility::platformIsOSX() ){

auto destPath = runTimeBinPath + "/yt-dlp_macos" ;
auto destPath = runTimeBinPath + "/" + _OSXBinaryName() ;
auto srcPath = utility::OSX3rdPartyDirPath() + "/" + _OSXBinaryName() ;

if( !QFile::exists( destPath ) ){

auto srcPath = utility::OSXApplicationDirPath() + "/extra/yt-dlp_macos" ;
if( !QFile::exists( destPath ) && QFile::exists( srcPath ) ){

utility::copyFile( srcPath,destPath ) ;
}
Expand Down Expand Up @@ -232,14 +236,16 @@ QJsonObject yt_dlp::init( const QString& name,

utility::addJsonCmd json( mainObj ) ;

auto macos = _OSXBinaryName() ;

json.add( { { "Generic" },{ { "x86","youtube-dl",{ "youtube-dl" } },
{ "amd64","youtube-dl",{ "youtube-dl" } } } } ) ;

json.add( { { "Windows" },{ { "x86","youtube-dl.exe",{ "youtube-dl.exe" } },
{ "amd64","youtube-dl.exe",{ "youtube-dl.exe" } } } } ) ;

json.add( { { "MacOS" },{ { "x86","yt-dlp_macos",{ "yt-dlp_macos" } },
{ "amd64","yt-dlp_macos",{ "yt-dlp_macos" } } } } ) ;
json.add( { { "MacOS" },{ { "x86",macos,{ macos } },
{ "amd64",macos,{ macos } } } } ) ;

json.done() ;

Expand All @@ -265,16 +271,17 @@ QJsonObject yt_dlp::init( const QString& name,
utility::addJsonCmd json( mainObj ) ;

auto x86Name = _Windows32BitBinaryName() ;
auto amd64 = _Windows64BitBinaryName() ;
auto amd64 = _Windows64BitBinaryName() ;
auto macos = _OSXBinaryName() ;

json.add( { { "Generic" },{ { "x86","yt-dlp",{ "yt-dlp" } },
{ "amd64","yt-dlp",{ "yt-dlp" } } } } ) ;

json.add( { { "Windows" },{ { "x86",x86Name,{ x86Name } },
{ "amd64",amd64,{ amd64 } } } } ) ;

json.add( { { "MacOS" },{ { "x86","yt-dlp_macos",{ "yt-dlp_macos" } },
{ "amd64","yt-dlp_macos",{ "yt-dlp_macos" } } } } ) ;
json.add( { { "MacOS" },{ { "x86",macos,{ macos } },
{ "amd64",macos,{ macos } } } } ) ;

json.done() ;

Expand Down
2 changes: 1 addition & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ QString settings::localizationLanguagePath()

if( utility::platformIsOSX() ){

return utility::OSXApplicationDirPath() + "/../Resources/translations" ;
return utility::OSXtranslationFilesPath() ;
}

if( !m_settings.contains( "TranslationsPath" ) ){
Expand Down
10 changes: 10 additions & 0 deletions src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,3 +2248,13 @@ QString utility::OSXApplicationDirPath()
{
return QCoreApplication::applicationDirPath() ;
}

QString utility::OSXtranslationFilesPath()
{
return utility::OSXApplicationDirPath() + "/../Resources/translations" ;
}

QString utility::OSX3rdPartyDirPath()
{
return utility::OSXApplicationDirPath() + "/extra" ;
}
2 changes: 2 additions & 0 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ namespace utility
void contextMenuForDirectUrl( const QJsonArray&,const Context& ) ;
void deleteTmpFiles( const QString&,std::vector< QByteArray > ) ;
QString OSXApplicationDirPath() ;
QString OSXtranslationFilesPath() ;
QString OSX3rdPartyDirPath() ;
QString windowsApplicationDirPath() ;
QString windowsGateWayAddress() ;
QString windowsGetClipBoardText( const ContextWinId& ) ;
Expand Down

0 comments on commit d53ad50

Please sign in to comment.