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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* smplayer, GUI front-end for mplayer.
Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "tvlist.h"
#include "favoriteeditor.h"
#include "images.h"
#include <QFile>
#include <QDir>
#include <QTextStream>
TVList::TVList(bool check_channels_conf, Services services, QString filename, QWidget * parent)
: Favorites(filename,parent)
{
#ifndef Q_OS_WIN
if (check_channels_conf) {
/* f_list.clear(); */
parse_channels_conf(services);
updateMenu();
}
#endif
}
TVList::~TVList() {
}
Favorites * TVList::createNewObject(QString filename, QWidget * parent) {
return new TVList(false, TV, filename, parent);
}
#ifndef Q_OS_WIN
void TVList::parse_channels_conf(Services services) {
qDebug("TVList::parse_channels_conf");
QString file = QDir::homePath() + "/.mplayer/channels.conf.ter";
if (!QFile::exists(file)) {
qDebug("VList::parse_channels_conf: %s doesn't exist", file.toUtf8().constData());
file = QDir::homePath() + "/.mplayer/channels.conf";
}
QFile f( file );
if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug("TVList::parse_channels_conf: can't open %s", file.toUtf8().constData());
return;
}
QTextStream in(&f);
while (!in.atEnd()) {
QString line = in.readLine();
qDebug("TVList::parse_channels_conf: '%s'", line.toUtf8().constData());
QString channel = line.section(':', 0, 0);
QString video_pid = line.section(':', 10, 10);
QString audio_pid = line.section(':', 11, 11);
bool is_radio = (video_pid == "0" && audio_pid != "0");
bool is_data = (video_pid == "0" && audio_pid == "0");
bool is_tv = (!is_radio && !is_data);
if (!channel.isEmpty()) {
qDebug("TVList::parse_channels_conf: channel: '%s' video_pid: %s audio_pid: %s", channel.toUtf8().constData(),video_pid.toUtf8().constData(),audio_pid.toUtf8().constData());
QString channel_id = "dvb://"+channel;
if (findFile(channel_id) == -1) {
if ( (services.testFlag(TVList::TV) && is_tv) ||
(services.testFlag(TVList::Radio) && is_radio) ||
(services.testFlag(TVList::Data) && is_data) )
{
f_list.append( Favorite(channel, channel_id) );
}
}
}
}
}
QString TVList::findChannelsFile() {
QString channels_file;
QString file = QDir::homePath() + "/.mplayer/channels.conf.ter";
if (QFile::exists(file)) return file;
file = QDir::homePath() + "/.mplayer/channels.conf";
if (QFile::exists(file)) return file;
file = QDir::homePath() + "/.config/mpv/channels.conf.ter";
if (QFile::exists(file)) return file;
file = QDir::homePath() + "/.config/mpv/channels.conf";
if (QFile::exists(file)) return file;
return QString::null;
}
#endif
void TVList::edit() {
qDebug("TVList::edit");
FavoriteEditor e(parent_widget);
e.setWindowTitle( tr("Channel editor") );
e.setCaption( tr("TV/Radio list") );
e.setDialogIcon( Images::icon("open_tv", 64) );
e.setData(f_list);
e.setStorePath( QFileInfo(_filename).absolutePath() );
if (e.exec() == QDialog::Accepted) {
f_list = e.data();
updateMenu();
}
}
#include "moc_tvlist.cpp"
|