2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "MusicFileDirectory.h"
13 #include "guilib/LocalizeStrings.h"
14 #include "utils/StringUtils.h"
15 #include "utils/URIUtils.h"
17 using namespace MUSIC_INFO
;
18 using namespace XFILE
;
20 CMusicFileDirectory::CMusicFileDirectory(void) = default;
22 CMusicFileDirectory::~CMusicFileDirectory(void) = default;
24 bool CMusicFileDirectory::GetDirectory(const CURL
& url
, CFileItemList
&items
)
26 std::string strPath
=url
.Get();
28 std::string strFileName
;
29 strFileName
= URIUtils::GetFileName(strPath
);
30 URIUtils::RemoveExtension(strFileName
);
32 int iStreams
= GetTrackCount(strPath
);
34 URIUtils::AddSlashAtEnd(strPath
);
36 for (int i
=0; i
<iStreams
; ++i
)
38 std::string strLabel
=
39 StringUtils::Format("{} - {} {:02}", strFileName
, g_localizeStrings
.Get(554), i
+ 1);
40 CFileItemPtr
pItem(new CFileItem(strLabel
));
41 strLabel
= StringUtils::Format("{}{}-{}.{}", strPath
, strFileName
, i
+ 1, m_strExt
);
42 pItem
->SetPath(strLabel
);
45 * Try fist to load tag about related stream track. If them fails or not
46 * available, take base tag for all streams (in this case the item names
49 MUSIC_INFO::CMusicInfoTag tag
;
50 if (Load(strLabel
, tag
, nullptr))
51 *pItem
->GetMusicInfoTag() = tag
;
52 else if (m_tag
.Loaded())
53 *pItem
->GetMusicInfoTag() = m_tag
;
56 * Check track number not set and take stream entry number about.
57 * NOTE: Audio decoder addons can also give a own track number.
59 if (pItem
->GetMusicInfoTag()->GetTrackNumber() == 0)
60 pItem
->GetMusicInfoTag()->SetTrackNumber(i
+1);
67 bool CMusicFileDirectory::Exists(const CURL
& url
)
72 bool CMusicFileDirectory::ContainsFiles(const CURL
&url
)
74 const std::string
pathToUrl(url
.Get());
75 if (GetTrackCount(pathToUrl
) > 1)