Diffstat (limited to 'noncore/multimedia/opieplayer2/om3u.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 790fa09..f2a01d3 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -29,28 +29,31 @@ | |||
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "om3u.h" | 32 | #include "om3u.h" |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
37 | 37 | ||
38 | //extern PlayListWidget *playList; | 38 | //extern PlayListWidget *playList; |
39 | 39 | ||
40 | Om3u::Om3u( const QString &filePath, int mode) | 40 | Om3u::Om3u( const QString &filePath, int mode) |
41 | : QStringList (){ | 41 | : QStringList () |
42 | { | ||
42 | odebug << "<<<<<<<new m3u "+filePath << oendl; | 43 | odebug << "<<<<<<<new m3u "+filePath << oendl; |
43 | f.setName(filePath); | 44 | f.setName(filePath); |
44 | f.open(mode); | 45 | if (!f.open(mode)) { |
46 | owarn << "Unable to open file " << f.name() << oendl; | ||
47 | } | ||
45 | } | 48 | } |
46 | 49 | ||
47 | Om3u::~Om3u(){} | 50 | Om3u::~Om3u(){} |
48 | 51 | ||
49 | void Om3u::readM3u() { | 52 | void Om3u::readM3u() { |
50 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; | 53 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; |
51 | QTextStream t(&f); | 54 | QTextStream t(&f); |
52 | t.setEncoding(QTextStream::UnicodeUTF8); | 55 | t.setEncoding(QTextStream::UnicodeUTF8); |
53 | QString s; | 56 | QString s; |
54 | while ( !t.atEnd() ) { | 57 | while ( !t.atEnd() ) { |
55 | s=t.readLine(); | 58 | s=t.readLine(); |
56 | // odebug << s << oendl; | 59 | // odebug << s << oendl; |
@@ -74,62 +77,52 @@ void Om3u::readM3u() { | |||
74 | 77 | ||
75 | void Om3u::readPls() { //it's a pls file | 78 | void Om3u::readPls() { //it's a pls file |
76 | QTextStream t( &f ); | 79 | QTextStream t( &f ); |
77 | t.setEncoding(QTextStream::UnicodeUTF8); | 80 | t.setEncoding(QTextStream::UnicodeUTF8); |
78 | QString s; | 81 | QString s; |
79 | while ( !t.atEnd() ) { | 82 | while ( !t.atEnd() ) { |
80 | s = t.readLine(); | 83 | s = t.readLine(); |
81 | if( s.left(4) == "File" ) { | 84 | if( s.left(4) == "File" ) { |
82 | s = s.right( s.length() - s.find("=",0,true)-1 ); | 85 | s = s.right( s.length() - s.find("=",0,true)-1 ); |
83 | s = s.stripWhiteSpace(); | 86 | s = s.stripWhiteSpace(); |
84 | s.replace( QRegExp( "%20" )," "); | 87 | s.replace( QRegExp( "%20" )," "); |
85 | // odebug << "adding " + s + " to playlist" << oendl; | 88 | // odebug << "adding " + s + " to playlist" << oendl; |
86 | // numberofentries=2 | ||
87 | // File1=http | ||
88 | // Title | ||
89 | // Length | ||
90 | // Version | ||
91 | // File2=http | ||
92 | s = s.replace( QRegExp( "\\" ), "/" ); | 89 | s = s.replace( QRegExp( "\\" ), "/" ); |
93 | QFileInfo f( s ); | 90 | QFileInfo f( s ); |
94 | QString name = f.baseName(); | 91 | QString name = f.baseName(); |
95 | if( name.left( 4 ) == "http" ) { | 92 | if( name.left( 4 ) == "http" ) { |
96 | name = s.right( s.length() - 7); | 93 | name = s.right( s.length() - 7); |
97 | } else { | 94 | } else { |
98 | name = s; | 95 | name = s; |
99 | } | 96 | } |
100 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 97 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
101 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 98 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
102 | append(s); | 99 | append(s); |
103 | else { //if its a url | 100 | else { //if its a url |
104 | // if( name.right( 1 ).find( '/' ) == -1) { | ||
105 | // s += "/"; | ||
106 | // } | ||
107 | append(s); | 101 | append(s); |
108 | } | 102 | } |
109 | } | 103 | } |
110 | } | 104 | } |
111 | } | 105 | } |
112 | 106 | ||
113 | void Om3u::write() { //writes list to m3u file | 107 | void Om3u::write() { //writes list to m3u file |
114 | QString list; | 108 | QString list; |
115 | QTextStream t(&f); | 109 | QTextStream t(&f); |
116 | t.setEncoding(QTextStream::UnicodeUTF8); | 110 | t.setEncoding(QTextStream::UnicodeUTF8); |
117 | if(count()>0) { | 111 | if(count()>0) { |
118 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 112 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
119 | // odebug << *it << oendl; | 113 | // odebug << *it << oendl; |
120 | t << *it << "\n"; | 114 | t << *it << "\n"; |
121 | } | 115 | } |
122 | } | 116 | } |
123 | // f.close(); | ||
124 | } | 117 | } |
125 | 118 | ||
126 | void Om3u::add(const QString &filePath) { //adds to m3u file | 119 | void Om3u::add(const QString &filePath) { //adds to m3u file |
127 | append(filePath); | 120 | append(filePath); |
128 | } | 121 | } |
129 | 122 | ||
130 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 123 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
131 | QString list, currentFile; | 124 | QString list, currentFile; |
132 | if(count()>0) { | 125 | if(count()>0) { |
133 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 126 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
134 | currentFile=*it; | 127 | currentFile=*it; |
135 | // odebug << *it << oendl; | 128 | // odebug << *it << oendl; |