blob: f2ec4e3f72bad17eef6472f09f93ca4878cc0f1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "PlayListURL.h"
#include "FileItem.h"
#include "filesystem/File.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
using namespace PLAYLIST;
using namespace XFILE;
// example url file
//[DEFAULT]
//BASEURL=http://msdn2.microsoft.com/en-us/library/ms812698.aspx
//[InternetShortcut]
//URL=http://msdn2.microsoft.com/en-us/library/ms812698.aspx
CPlayListURL::CPlayListURL(void) = default;
CPlayListURL::~CPlayListURL(void) = default;
bool CPlayListURL::Load(const std::string& strFileName)
{
char szLine[4096];
std::string strLine;
Clear();
m_strPlayListName = URIUtils::GetFileName(strFileName);
URIUtils::GetParentPath(strFileName, m_strBasePath);
CFile file;
if (!file.Open(strFileName) )
{
file.Close();
return false;
}
while (file.ReadString(szLine, 1024))
{
strLine = szLine;
StringUtils::RemoveCRLF(strLine);
if (StringUtils::StartsWith(strLine, "[InternetShortcut]"))
{
if (file.ReadString(szLine,1024))
{
strLine = szLine;
StringUtils::RemoveCRLF(strLine);
if (StringUtils::StartsWith(strLine, "URL="))
{
CFileItemPtr newItem(new CFileItem(strLine.substr(4), false));
Add(newItem);
}
}
}
}
file.Close();
return true;
}
|