[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 3 |
|
---|
| 4 | This program is free software; you can redistribute it and/or modify
|
---|
| 5 | it under the terms of the GNU General Public License as published by
|
---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
---|
| 7 | (at your option) any later version.
|
---|
| 8 |
|
---|
| 9 | This program is distributed in the hope that it will be useful,
|
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 12 | GNU General Public License for more details.
|
---|
| 13 |
|
---|
| 14 | You should have received a copy of the GNU General Public License
|
---|
| 15 | along with this program; if not, write to the Free Software
|
---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | #include "extensions.h"
|
---|
[181] | 20 | #include <QDebug>
|
---|
[112] | 21 |
|
---|
| 22 | ExtensionList::ExtensionList() : QStringList()
|
---|
| 23 | {
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | QString ExtensionList::forFilter() {
|
---|
| 27 | QString s;
|
---|
| 28 | for (int n=0; n < count(); n++) {
|
---|
| 29 | s = s + "*." + at(n) + " ";
|
---|
| 30 | }
|
---|
| 31 | if (!s.isEmpty()) s = " (" + s + ")";
|
---|
| 32 | return s;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
[165] | 35 | QStringList ExtensionList::forDirFilter() {
|
---|
| 36 | QStringList l;
|
---|
| 37 | for (int n=0; n < count(); n++) {
|
---|
| 38 | QString s = "*." + at(n);
|
---|
| 39 | l << s;
|
---|
| 40 | }
|
---|
| 41 | return l;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[112] | 44 | QString ExtensionList::forRegExp() {
|
---|
| 45 | QString s;
|
---|
| 46 | for (int n=0; n < count(); n++) {
|
---|
| 47 | if (!s.isEmpty()) s = s + "|";
|
---|
| 48 | s = s + "^" + at(n) + "$";
|
---|
| 49 | }
|
---|
| 50 | return s;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | Extensions::Extensions()
|
---|
| 54 | {
|
---|
| 55 | _video << "avi" << "vfw" << "divx"
|
---|
| 56 | << "mpg" << "mpeg" << "m1v" << "m2v" << "mpv" << "dv" << "3gp"
|
---|
| 57 | << "mov" << "mp4" << "m4v" << "mqv"
|
---|
| 58 | << "dat" << "vcd"
|
---|
[135] | 59 | << "ogg" << "ogm" << "ogv" << "ogx"
|
---|
[112] | 60 | << "asf" << "wmv"
|
---|
| 61 | << "bin" << "iso" << "vob"
|
---|
| 62 | << "mkv" << "nsv" << "ram" << "flv"
|
---|
| 63 | << "rm" << "swf"
|
---|
[142] | 64 | << "ts" << "rmvb" << "dvr-ms" << "m2t" << "m2ts" << "mts" << "rec" << "wtv"
|
---|
| 65 | << "f4v" << "hdmov" << "webm" << "vp8"
|
---|
[170] | 66 | << "bik" << "smk" << "m4b" << "wtv";
|
---|
[112] | 67 |
|
---|
[142] | 68 | _audio << "mp3" << "ogg" << "oga" << "wav" << "wma" << "aac" << "ac3" << "dts" << "ra" << "ape" << "flac" << "thd" << "mka" << "m4a";
|
---|
[112] | 69 |
|
---|
| 70 | _subtitles << "srt" << "sub" << "ssa" << "ass" << "idx" << "txt" << "smi"
|
---|
| 71 | << "rt" << "utf" << "aqt";
|
---|
| 72 |
|
---|
[176] | 73 | _playlist << "m3u" << "m3u8" << "pls" << "xspf";
|
---|
[112] | 74 |
|
---|
| 75 | _multimedia = _video;
|
---|
| 76 | for (int n = 0; n < _audio.count(); n++) {
|
---|
| 77 | if (!_multimedia.contains(_audio[n])) _multimedia << _audio[n];
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | _all_playable << _multimedia << _playlist;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | Extensions::~Extensions() {
|
---|
| 84 | }
|
---|
| 85 |
|
---|
[181] | 86 | QString Extensions::extensionFromUrl(const QString & url) {
|
---|
| 87 | //qDebug() << "Extensions::extensionFromUrl:" << url;
|
---|
| 88 |
|
---|
| 89 | QString extension;
|
---|
| 90 | int pos = url.lastIndexOf(".");
|
---|
| 91 | if (pos != -1) {
|
---|
| 92 | extension = url.mid(pos+1).toLower();
|
---|
| 93 | // Check if extension contains a '?' and remove everything after it
|
---|
| 94 | pos = extension.lastIndexOf("?");
|
---|
| 95 | if (pos != -1) {
|
---|
| 96 | extension = extension.left(pos);
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | //qDebug() << "Extensions::extensionFromUrl: extension:" << extension;
|
---|
| 101 | return extension;
|
---|
| 102 | }
|
---|
| 103 |
|
---|