kget: remove content fetch plugin

reference:
https://github.com/fluxer/katana/issues/12

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-03-26 22:04:44 +02:00
parent cb397b6a75
commit 0d85ac3d6b
28 changed files with 0 additions and 2319 deletions

View file

@ -3,7 +3,6 @@ add_subdirectory(multisegmentkio)
add_subdirectory(metalink)
add_subdirectory(bittorrent)
add_subdirectory(mirrorsearch)
#add_subdirectory(contentfetch)
if (LIBMMS_FOUND)
add_subdirectory(mmsthreads)
endif (LIBMMS_FOUND)

View file

@ -1,45 +0,0 @@
add_subdirectory(scripts)
include_directories(
../../
)
set(kget_contentfetchfactory_PART_SRCS
contentfetch.cpp
contentfetchfactory.cpp
script.cpp
scriptdownloadengine.cpp
scriptconfigadaptor.cpp
)
kde4_add_kcfg_files(kget_contentfetchfactory_PART_SRCS contentfetchsetting.kcfgc)
kde4_add_plugin(kget_contentfetchfactory ${kget_contentfetchfactory_PART_SRCS})
target_link_libraries(kget_contentfetchfactory
${KDE4_KIO_LIBS}
${KDE4_KROSSCORE_LIBS}
${KDE4_KROSSUI_LIBS}
kgetcore
)
install(TARGETS kget_contentfetchfactory DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
install(FILES kget_contentfetchfactory.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
install(FILES kget_contentfetchfactory.kcfg DESTINATION ${KDE4_KCFG_INSTALL_DIR})
###Build KCM-Module
set(kcm_kget_contentfetchfactory_PART_SRCS
dlgcontentfetchsettingwidget.cpp
dlgscriptediting.cpp
scriptconfigadaptor.cpp
dlgcontentfetchsettingwidget.ui
dlgscriptediting.ui
)
kde4_add_kcfg_files(kcm_kget_contentfetchfactory_PART_SRCS contentfetchsetting.kcfgc)
kde4_add_plugin(kcm_kget_contentfetchfactory ${kcm_kget_contentfetchfactory_PART_SRCS})
target_link_libraries(kcm_kget_contentfetchfactory ${KDE4_KIO_LIBS}
${KDE4_KROSSCORE_LIBS} ${KDE4_KROSSUI_LIBS})
install(TARGETS kcm_kget_contentfetchfactory DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
install(FILES kget_contentfetchfactory_config.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})

View file

@ -1,126 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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 file describes how to write a script using the kross interface from
the content fetch plugin.
== API ==
=== Functions ===
Script developer must implement certain functions in the
script to be called by the content fetch plugin.
* startDownload(config) (MUST implement)
config: SciptConfigAdaptor type
Descrption:
KGet will call this function when it gets the url from the user
input and are ready to start the download process. This is the main
entry point of the script.
* configureScript(widget, config) (Optional)
Parameter:
widget: SettingWidgetAddptor (QWidget) type
config: SciptConfigAdaptor type
Description:
If your script need config options, and you have implement a ui to
show them (eg. via pyqt/pykde) , you will need this one. General way
to do this is to implement your own QWidget subclass and call
widget.setWidget(your_widget) to show it. You might use the config to
deal with ini style file conveniently.
* configurationAccepted(widget, config) (Optional)
Parameter:
widget: SettingWidgetAddptor (QWidget) type
config: SciptConfigAdaptor type
Description:
This function is called when user click 'ok' from the setting ui.
Generally you should save your options, possibly with the help of
the 'config' object.
=== Class ===
Some objects are not directly exposed to script, they are passed
in through the function arguments. Here describe their types.
* ScriptConfigAdaptor
** void setWidget(widget)
Parameter:
widget: QWidget type
Description:
The 'widget' should be your own script setting ui widget, once
you are ready with your widget, call this function to show it.
* SettingWidgetAdaptor
Description:
This class is a helper class to provide a parser for the convenience
to load/save the configuration file.
Functions:
** void setFile(config_file, path = "")
Parameter:
config_file: QString/string, config file name
path: QString/string, optional. The path of the config file, if
omitted, default value is the $KDEUSERDIR/share/app/kget/contentfetch_scripts_setting/
Description:
Initial the file, must be called before any read/write.
** void unsetFile()
Description:
Free the file resource, ready to call setFile() again.
** QVariant read(group, key, default_value)
Parameters:
group: string, section name
key: string, key name
default_value: int/double/string/list/stringlist
Description:
Read specific value from config, if not found, return default_value.
** void write()
Parameters:
group: string, section name
key: string, key name
value: int/double/string/list/stringlist
Description:
Change specific value in the config.
** void save()
Description:
Save the config data into file.
** void reset()
Abandon changes in the config data, reread from file.
=== Object ===
Objects are pointers exported to script using the kross lib,to use these
objects, you must import them first.
E.g. In python, you do 'import kgetcore'
* kgetcore
** void addTransfer(sourceUrl, filename)
Parameter:
sourceUrl: QString/string
filename: QString/string, optional
Description:
Add the sourceUrl into the kget transferlist with the download file
set to 'filename'. If filename is ommitted, then kget will determine
the filename.
** string getSourceUrl()
Description:
Return the sourceurl from user input.
** void finish()
Description:
Notify kget the processing of the script finishes, should be called
at the end of the script.
** void abort(error_message = "")
Parameter:
error_message: QString/string, optional
Description:
Notify kget the script has failed with the error message.
== NOTICE ==
* Don't use threading/thread function within python, it will freeze kget
(due to some GIL related issue?). Just write old-styled serialized
program. Same thing for other languages. This might be solved with the
improvement of kross.

View file

@ -1,116 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#include "contentfetch.h"
#include "core/kget.h"
#include "core/transfergroup.h"
#include "script.h"
#include <kiconloader.h>
#include <klocale.h>
#include <KDebug>
#include <KMessageBox>
#include <KUrl>
#include <kross/core/manager.h>
#include <kross/core/action.h>
#include <QtXml/qdom.h>
#include <QFile>
#include <QString>
ContentFetch::ContentFetch(TransferGroup* parent, TransferFactory* factory,
Scheduler* scheduler, const KUrl& source,
const KUrl& dest, const QString &scriptFile,
const QDomElement* e)
: Transfer(parent, factory, scheduler, source, dest, e),
m_p_group(parent), m_scriptFile(scriptFile), m_destDir(dest.directory(KUrl::AppendTrailingSlash))
{
m_p_script = new Script(this, source);
connect(m_p_script, SIGNAL(newTransfer(QString,QString)),
this, SLOT(slotAddTransfer(QString,QString)));
connect(m_p_script, SIGNAL(finished()), this, SLOT(slotFinish()));
connect(m_p_script, SIGNAL(aborted(QString)), this, SLOT(slotAbort(QString)));
connect(m_p_script, SIGNAL(percentUpdated(int)), this, SLOT(setPercent(int)));
connect(m_p_script, SIGNAL(textStatusUpdated(QString)), this, SLOT(slotSetTextStatus(QString)));
}
void ContentFetch::deinit()
{
return;
}
void ContentFetch::start()
{
kDebug(5001) << "ContentFetch::start";
setStatus(Job::Running, i18nc("Transfer state: processing script", "Processing script...."), SmallIcon("media-playback-start"));
setTransferChange(Tc_Status, true);
m_p_script->setFile(m_scriptFile);
m_p_script->start();
kDebug(5001) << "ContentFetch::start() finished!";
}
void ContentFetch::stop()
{
if(status() == Stopped)
{
return;
}
kDebug(5001) << "ContentFetch::stop";
// kill -9 the script
m_p_script->terminate();
// delete m_p_script to avoid crash?
setStatus(Job::Stopped, i18nc("transfer state: stopped", "Stopped"), SmallIcon("process-stop"));
setTransferChange(Tc_Status, true);
}
void ContentFetch::slotAddTransfer(const QString &url, const QString &filename)
{
// even if filename is empty it's still ok
kDebug() << "The whole filename is " << m_destDir + filename;
KGet::addTransfer(KUrl(url), m_destDir + filename, m_p_group->name(), true);
}
void ContentFetch::slotFinish()
{
m_percent = 100;
setStatus(Job::Finished, i18nc("Transfer State: Finished", "Finished"), SmallIcon("dialog-ok"));
setTransferChange(Tc_Status|Tc_Percent, true);
//delete m_p_script;
}
void ContentFetch::slotAbort(const QString &error)
{
if (error.isEmpty())
{
setStatus(Job::Aborted, i18nc("Transfer State: Aborted", "Aborted"), SmallIcon("process-stop"));
}
else
{
setStatus(Job::Aborted, error, SmallIcon("process-stop"));
}
setTransferChange(Tc_Status, true);
}
void ContentFetch::slotSetTextStatus(const QString& text)
{
setStatus(Job::Running, text, SmallIcon("media-playback-start"));
setTransferChange(Tc_Status, true);
}
bool ContentFetch::isResumable() const
{
return false;
}
void ContentFetch::setPercent(int percent)
{
m_percent = percent;
setTransferChange( Transfer::Tc_Percent, true );
}

View file

@ -1,52 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#ifndef CONTENT_FETCH_H
#define CONTENT_FETCH_H
#include "core/transfer.h"
#include "script.h"
#include <QString>
class ContentFetch : public Transfer
{
Q_OBJECT
public:
ContentFetch(TransferGroup * parent, TransferFactory * factory,
Scheduler * scheduler, const KUrl & src,
const KUrl & dest, const QString &scriptFile,
const QDomElement * e = 0);
public slots:
void deinit();
// --- Job virtual functions ---
void start();
void stop();
bool isResumable() const;
void setPercent(int percent);
private:
Script *m_p_script;
TransferGroup *m_p_group;
QString m_scriptFile;
QString m_destDir;
private slots:
void slotFinish();
void slotAbort(const QString&);
void slotAddTransfer(const QString &url, const QString &filename);
void slotSetTextStatus(const QString& text);
};
#endif // CONTENT_FETCH_H

View file

@ -1,96 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#include "contentfetchfactory.h"
#include "core/scheduler.h"
#include "core/transfergroup.h"
#include "contentfetch.h"
#include "contentfetchsetting.h"
#include <QStringList>
#include <QList>
#include <QRegExp>
#include <QtGlobal>
#include <KDebug>
KGET_EXPORT_PLUGIN( ContentFetchFactory )
ContentFetchFactory::ContentFetchFactory(QObject *parent,
const QVariantList &args)
: TransferFactory(parent, args)
{
}
ContentFetchFactory::~ContentFetchFactory()
{
}
Transfer * ContentFetchFactory::createTransfer( const KUrl &srcUrl,
const KUrl &destUrl,
TransferGroup * parent,
Scheduler * scheduler,
const QDomElement * e )
{
QStringList scriptPathList;
QVector<QRegExp> regexpList;
QStringList allRegexpList = ContentFetchSetting::self()->urlRegexpList();
QStringList allScriptPathList = ContentFetchSetting::self()->pathList();
QList<int> allEnableList = ContentFetchSetting::self()->enableList();
// TODO: change to notify user without crash
// Q_ASSERT_X(scriptPathList.size() == regexpList.size(), "kcfg File", "Contentfetch config file corrupted!");
for (int i = 0; i < allRegexpList.size(); ++i)
{
if (allEnableList[i])
{
regexpList.push_back(QRegExp(allRegexpList[i]));
scriptPathList.push_back(allScriptPathList[i]);
}
}
// No user script exists
if (regexpList.size() == 0)
{
return 0;
}
QString url = srcUrl.url();
QStringList::iterator fileIter = scriptPathList.begin();
for(QVector<QRegExp>::iterator iter = regexpList.begin();
iter != regexpList.end(); ++iter, ++fileIter)
{
if (iter->indexIn(url) != -1)
{
kDebug(5001) << url << " match " << iter->pattern();
return new ContentFetch(parent, this, scheduler, srcUrl, destUrl,
*fileIter, e);
}
}
return 0;
}
TransferHandler * ContentFetchFactory::createTransferHandler(
Transfer * transfer,
Scheduler * scheduler)
{
return new TransferHandler(transfer, scheduler);
}
QWidget * ContentFetchFactory::createDetailsWidget(TransferHandler *transfer)
{
Q_UNUSED(transfer)
return 0; //Temporary!!
}
const QList<KAction*> ContentFetchFactory::actions(TransferHandler *handler)
{
Q_UNUSED(handler)
return QList<KAction*>();
}

View file

@ -1,42 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2004 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#ifndef CONTENT_FETCH_FACTORY_H
#define CONTENT_FETCH_FACTORY_H
#include "core/plugin/transferfactory.h"
#include <QStringList>
#include <QList>
class Transfer;
class TransferGroup;
class Scheduler;
class ContentFetchFactory : public TransferFactory
{
Q_OBJECT
public:
ContentFetchFactory(QObject *parent, const QVariantList &args);
~ContentFetchFactory();
Transfer * createTransfer( const KUrl &srcUrl, const KUrl &destUrl,
TransferGroup * parent, Scheduler * scheduler,
const QDomElement * e = 0 );
TransferHandler * createTransferHandler(Transfer * transfer,
Scheduler * scheduler);
QWidget * createDetailsWidget( TransferHandler * transfer );
const QList<KAction *> actions(TransferHandler *handler = 0);
};
#endif // CONTENT_FETCH_FACTORY_H

View file

@ -1,6 +0,0 @@
ClassName=ContentFetchSetting
File=kget_contentfetchfactory.kcfg
Mutators=true
Singleton=true
Visibility=KDE_EXPORT
IncludeFiles=kstandarddirs.h

View file

@ -1,261 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#include "dlgcontentfetchsettingwidget.h"
#include "dlgscriptediting.h"
#include "contentfetchsetting.h"
#include "scriptconfigadaptor.h"
#include "kget_export.h"
#include <QSize>
#include <kdialog.h>
#include <kdebug.h>
KGET_EXPORT_PLUGIN_CONFIG(DlgContentFetchSettingWidget)
DlgContentFetchSettingWidget::DlgContentFetchSettingWidget(QWidget * parent = 0, const QVariantList &args = QVariantList())
: KCModule(KGetFactory::componentData(), parent, args),
m_p_action(0)
{
ui.setupUi(this);
ui.newScriptButton->setIcon(KIcon("list-add"));
ui.removeScriptButton->setIcon(KIcon("list-remove"));
loadContentFetchSetting();
connect(ui.newScriptButton, SIGNAL(clicked()), this, SLOT(slotNewScript()));
connect(ui.editScriptButton, SIGNAL(clicked()), this, SLOT(slotEditScript()));
connect(ui.configureScriptButton, SIGNAL(clicked()), this, SLOT(slotConfigureScript()));
connect(ui.removeScriptButton, SIGNAL(clicked()), this, SLOT(slotRemoveScript()));
connect(ui.scriptTreeWidget,
SIGNAL(itemClicked(QTreeWidgetItem*,int)),
this, SLOT(slotCheckConfigurable(QTreeWidgetItem*,int)));
connect(ui.scriptTreeWidget,
SIGNAL(itemChanged(QTreeWidgetItem*,int)),
this, SLOT(slotEnableChanged(QTreeWidgetItem*,int)));
}
DlgContentFetchSettingWidget::~DlgContentFetchSettingWidget()
{
}
void DlgContentFetchSettingWidget::slotNewScript()
{
QPointer<DlgScriptEditing> dialog = new DlgScriptEditing(this);
if (dialog->exec())
{
addScriptItem(true, dialog->scriptPath(), dialog->scriptUrlRegexp(),
dialog->scriptDescription());
}
changed();
}
void DlgContentFetchSettingWidget::slotEditScript()
{
QList<QTreeWidgetItem *> selectedItems =
ui.scriptTreeWidget->selectedItems();
// only edit one item at one time
if (selectedItems.size()!=1)
{
return;
}
QTreeWidgetItem &item = *(selectedItems[0]);
QPointer<DlgScriptEditing> dialog = new DlgScriptEditing(this, (QStringList() << item.toolTip(0)
<< item.text(1) << item.text(2)));
if (dialog->exec())
{
if (item.toolTip(0) != dialog->scriptPath())
{
item.setText(0, QFileInfo(dialog->scriptPath()).fileName());
item.setToolTip(0, dialog->scriptPath());
changed();
}
if (item.text(1) != dialog->scriptUrlRegexp())
{
item.setText(1, dialog->scriptUrlRegexp());
changed();
}
if (item.text(2) != dialog->scriptDescription())
{
item.setText(2, dialog->scriptDescription());
changed();
}
}
}
void DlgContentFetchSettingWidget::slotConfigureScript()
{
QList<QTreeWidgetItem *> selectedItems =
ui.scriptTreeWidget->selectedItems();
// only configure one item at one time
if (selectedItems.size()!=1)
{
return;
}
QString filename = selectedItems[0]->toolTip(0);
if (m_p_action)
{
delete m_p_action;
}
m_p_action = new Kross::Action(this, QString("%1_ContentFetchConfig").arg(filename));
// TODO add check file
m_p_action->setFile(filename);
m_p_action->addObject(this, "kgetscriptconfig",
Kross::ChildrenInterface::AutoConnectSignals);
m_p_action->trigger();
KDialog *dialog = new KDialog(this);
dialog->setObjectName("configure_script");
dialog->setCaption(i18nc("Configure script", "Configure script"));
dialog->enableButtonOk(false);
dialog->setModal(true);
SettingWidgetAdaptor *widget = new SettingWidgetAdaptor(dialog);
ScriptConfigAdaptor config;
emit configureScript(widget,&config);
if (widget->findChild<QWidget*>())
{
dialog->enableButtonOk(true);
}
dialog->setMainWidget(widget);
dialog->showButtonSeparator(true);
// dirty hack, add the ok/canel button size manually
dialog->resize(widget->size()+QSize(0,30));
dialog->show();
if (dialog->exec() == QDialog::Accepted)
{
emit configurationAccepted(widget, &config);
}
dialog->deleteLater();
}
void DlgContentFetchSettingWidget::slotRemoveScript()
{
QList<QTreeWidgetItem *> selectedItems =
ui.scriptTreeWidget->selectedItems();
foreach(QTreeWidgetItem * selectedItem, selectedItems)
delete(selectedItem);
changed();
}
void DlgContentFetchSettingWidget::addScriptItem(bool enabled, const QString &path, const QString &regexp, const QString &description)
{
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << QFileInfo(path).fileName() << regexp << description);
item->setToolTip(0, path);
item->setCheckState(0, enabled ? Qt::Checked : Qt::Unchecked);
ui.scriptTreeWidget->addTopLevelItem(item);
}
void DlgContentFetchSettingWidget::loadContentFetchSetting()
{
ui.scriptTreeWidget->clear();//Cleanup things first
QStringList paths = ContentFetchSetting::self()->pathList();
QStringList regexps = ContentFetchSetting::self()->urlRegexpList();
QStringList descriptions = ContentFetchSetting::self()->descriptionList();
QList<int> enables = ContentFetchSetting::self()->enableList();
// TODO: add some safety check to avoid crashing when user rc got corrputed.
for (int i = 0; i < paths.size(); ++i)
{
addScriptItem(bool(enables[i]), paths[i], regexps[i], descriptions[i]);
}
}
void DlgContentFetchSettingWidget::saveContentFetchSetting()
{
kDebug(5002);
QStringList paths;
QStringList regexps;
QStringList descriptions;
QList<int> enables;
for (int i = 0; i < ui.scriptTreeWidget->topLevelItemCount(); ++i)
{
paths.append(ui.scriptTreeWidget->topLevelItem(i)->toolTip(0));
regexps.append(ui.scriptTreeWidget->topLevelItem(i)->text(1));
descriptions.append(ui.scriptTreeWidget->topLevelItem(i)->text(2));
if (ui.scriptTreeWidget->topLevelItem(i)->checkState(0) == Qt::Unchecked)
{
enables.append(0);
}
else
{
enables.append(1);
}
}
ContentFetchSetting::self()->setPathList(paths);
ContentFetchSetting::self()->setUrlRegexpList(regexps);
ContentFetchSetting::self()->setDescriptionList(descriptions);
ContentFetchSetting::self()->setEnableList(enables);
ContentFetchSetting::self()->writeConfig();
}
void DlgContentFetchSettingWidget::save()
{
saveContentFetchSetting();
// NOTICE: clean the last config script, might change in the furture
if (m_p_action)
{
delete m_p_action;
m_p_action = 0;
}
}
void DlgContentFetchSettingWidget::load()
{
// clean the last config script
if (m_p_action)
{
delete m_p_action;
m_p_action = 0;
}
// this class is never destroyed, so reload the rc file into ui to sync
loadContentFetchSetting();
}
void DlgContentFetchSettingWidget::slotCheckConfigurable(QTreeWidgetItem *p_item,
int column )
{
if (column == -1)
{
return;
}
QString filename = p_item->toolTip(0);
Kross::Action action(this, QString("%1_CheckConfig").arg(filename));
// TODO add check file
action.setFile(filename);
action.trigger();
if (action.functionNames().contains("configureScript"))
{
ui.configureScriptButton->setEnabled(true);
}
else
{
ui.configureScriptButton->setEnabled(false);
}
}
void DlgContentFetchSettingWidget::slotEnableChanged(QTreeWidgetItem* p_item,
int column)
{
Q_UNUSED(p_item)
if (column != 0)
{
return;
}
changed();
}

View file

@ -1,70 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#ifndef DLG_CONTENT_FETCH_SETTING_H
#define DLG_CONTENT_FETCH_SETTING_H
#include <KCModule>
#include "ui_dlgcontentfetchsettingwidget.h"
#include <QPointer>
#include <kross/core/action.h>
class DlgContentFetchSettingWidget : public KCModule
{
Q_OBJECT
public:
DlgContentFetchSettingWidget(QWidget * parent, const QVariantList &args);
~DlgContentFetchSettingWidget();
public slots:
virtual void save();
virtual void load();
private slots:
void slotNewScript();
void slotEditScript();
void slotConfigureScript();
void slotRemoveScript();
void slotCheckConfigurable(QTreeWidgetItem *p_item,
int column);
void slotEnableChanged(QTreeWidgetItem* p_item,
int column);
signals:
void configureScript(QWidget* widget, QObject* configadaptor);
void configurationAccepted(QWidget* widget, QObject* configadaptor);
private:
void addScriptItem(bool enabled, const QString &path, const QString &regexp,
const QString &description);
void loadContentFetchSetting();
void saveContentFetchSetting();
Ui::DlgContentFetchSettingWidget ui;
QPointer<Kross::Action> m_p_action;
};
class SettingWidgetAdaptor : public QWidget
{
Q_OBJECT
public:
explicit SettingWidgetAdaptor(QWidget* parent = 0) : QWidget(parent) {}
virtual ~SettingWidgetAdaptor() {}
public slots:
void setWidget(QWidget* widget)
{
widget->setParent(this);
// make this widget same size as the user supplied one
// this will make resize easier from outside.
resize(widget->size());
}
};
#endif // DLG_CONTENT_FETCH_SETTING_H

View file

@ -1,98 +0,0 @@
<ui version="4.0" >
<class>DlgContentFetchSettingWidget</class>
<widget class="QWidget" name="DlgContentFetchSettingWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<height>534</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="KTitleWidget" name="ktitlewidget" >
<property name="text" >
<string>User Scripts</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="scriptTreeWidget" >
<property name="rootIsDecorated" >
<bool>false</bool>
</property>
<column>
<property name="text" >
<string>Path</string>
</property>
</column>
<column>
<property name="text" >
<string>RegExp</string>
</property>
</column>
<column>
<property name="text" >
<string>Description</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="spacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>13</width>
<height>29</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="newScriptButton" >
<property name="text" >
<string>New Script....</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeScriptButton" >
<property name="text" >
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editScriptButton" >
<property name="text" >
<string>Edit....</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="configureScriptButton" >
<property name="text" >
<string>Configure....</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KTitleWidget</class>
<extends>QWidget</extends>
<header>ktitlewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -1,91 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#include "dlgscriptediting.h"
#include "contentfetchsetting.h"
#include <kross/core/manager.h>
#include <kross/core/interpreter.h>
#include <kfiledialog.h>
DlgScriptEditing::DlgScriptEditing(QWidget *p_parent)
: KDialog(p_parent)
{
QWidget *mainWidget = new QWidget(this);
ui.setupUi(mainWidget);
setMainWidget(mainWidget);
setWindowTitle(i18n("Add New Script"));
init();
}
DlgScriptEditing::DlgScriptEditing(QWidget *p_parent,
const QStringList &script)
: KDialog(p_parent)
{
QWidget *mainWidget = new QWidget(this);
ui.setupUi(mainWidget);
setMainWidget(mainWidget);
setWindowTitle(i18n("Edit Script"));
ui.scriptPathRequester->setUrl(KUrl::fromPath(script[0]));
ui.scriptUrlRegexpEdit->setText(script[1]);
ui.scriptDescriptionEdit->setText(script[2]);
init();
}
void DlgScriptEditing::init()
{
ui.scriptPathRequester->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly);
ui.scriptPathRequester->fileDialog()->setCaption(i18n("Set Script File"));
QStringList filter;
foreach(Kross::InterpreterInfo* info, Kross::Manager::self().interpreterInfos())
filter << info->mimeTypes().join(" ");
ui.scriptPathRequester->setFilter(filter.join(" "));
setModal(true);
setButtons(KDialog::Ok | KDialog::Cancel);
showButtonSeparator(true);
connect(ui.scriptPathRequester,SIGNAL(textChanged(QString)),
this, SLOT(slotChangeText()));
connect(ui.scriptUrlRegexpEdit,SIGNAL(textChanged(QString)),
this, SLOT(slotChangeText()));
connect(ui.scriptDescriptionEdit,SIGNAL(textChanged(QString)),
this, SLOT(slotChangeText()));
}
DlgScriptEditing::~DlgScriptEditing()
{
}
void DlgScriptEditing::slotChangeText()
{
enableButton(KDialog::Ok, !(ui.scriptPathRequester->url().isEmpty() ||
ui.scriptUrlRegexpEdit->text().isEmpty()));
}
QString DlgScriptEditing::scriptPath() const
{
return ui.scriptPathRequester->url().toLocalFile();
}
QString DlgScriptEditing::scriptUrlRegexp() const
{
return ui.scriptUrlRegexpEdit->text();
}
QString DlgScriptEditing::scriptDescription() const
{
return ui.scriptDescriptionEdit->text();
}

View file

@ -1,36 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#ifndef DLG_SCRIPT_EDITING_H
#define DLG_SCRIPT_EDITING_H
#include "ui_dlgscriptediting.h"
#include <QStringList>
class DlgScriptEditing : public KDialog
{
Q_OBJECT
public:
DlgScriptEditing(QWidget *p_parent);
DlgScriptEditing(QWidget *p_parent, const QStringList &script);
~DlgScriptEditing();
void init();
QString scriptPath() const;
QString scriptUrlRegexp() const;
QString scriptDescription() const;
private slots:
void slotChangeText();
private:
Ui::DlgScriptEditing ui;
};
#endif // DLG_SCRIPT_EDITING_H

View file

@ -1,72 +0,0 @@
<ui version="4.0" >
<class>DlgScriptEditing</class>
<widget class="QWidget" name="DlgScriptEditing" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>132</height>
</rect>
</property>
<layout class="QGridLayout" >
<item row="5" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>361</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="scriptUrlRegexpLabel" >
<property name="text" >
<string>Regexp:</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="scriptPathLabel" >
<property name="text" >
<string>Path:</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="scriptDescriptionLabel" >
<property name="text" >
<string>Description:</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="KLineEdit" name="scriptDescriptionEdit" />
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="scriptUrlRegexpEdit" />
</item>
<item row="0" column="1" >
<widget class="KUrlRequester" name="scriptPathRequester" />
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -1,132 +0,0 @@
[Desktop Entry]
# service definition
Type=Service
X-KDE-ServiceTypes=KGet/Plugin
Icon=kget
# standard fields
Name=Content Fetch
Name[ar]=جلب المحتوى
Name[ast]=Content Fetch
Name[bg]=Изтегляне на съдържание
Name[bs]=Dobavljač sadržaja
Name[ca]=Obtén contingut
Name[ca@valencia]=Obtén contingut
Name[cs]=Stažení obsahu
Name[da]=Content Fetch
Name[de]=Daten laden
Name[el]=Ανάκτηση περιεχομένου
Name[en_GB]=Content Fetch
Name[es]=Content Fetch
Name[et]=Sisutõmbaja
Name[eu]=Eskuratu edukia
Name[fi]=Sisältönouto
Name[fr]=Rechercher un contenu
Name[ga]=Content Fetch
Name[gl]=Obter contidos
Name[hne]=
Name[hr]=Dohvaćanje sadržaja
Name[hu]=Letöltés
Name[ia]=Reporta contento
Name[is]=Ná í innihald
Name[it]=Scaricamento di contenuti
Name[ja]=
Name[kk]=Мазмұнын алу
Name[km]=
Name[ko]=
Name[lt]=Turinio atsiuntimas
Name[lv]=Satura ielāde
Name[ml]=
Name[nb]=Hent innhold
Name[nds]=Inholt halen
Name[nl]=Inhoud ophalen
Name[nn]=Innhaldshenting
Name[pa]=
Name[pl]=Pobieranie treści
Name[pt]=Obtenção de Conteúdo
Name[pt_BR]=Captura de conteúdo
Name[ro]=Preluare conținut
Name[ru]=Получение содержимое
Name[si]=
Name[sk]=Získanie obsahu
Name[sl]=Pridobivanje vsebine
Name[sr]=Добављач садржаја
Name[sr@ijekavian]=Добављач садржаја
Name[sr@ijekavianlatin]=Dobavljač sadržaja
Name[sr@latin]=Dobavljač sadržaja
Name[sv]=Hämta innehåll
Name[th]=
Name[tr]=İçerik Getir
Name[ug]=مەزمۇنغا ئېرىشكۈچ
Name[uk]=Отримання вмісту
Name[x-test]=xxContent Fetchxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Fetch contents with custom scripts.
Comment[ar]=جلب المحتوى بسكريبتات مخصصة
Comment[ast]=Conteníos trayíos con guión especificáu
Comment[bg]=Изтегляне на съдържание със специални скриптове.
Comment[bs]=Dobavlja sadržaje pomoću posebnih skripti.
Comment[ca]=Agafa continguts amb scripts personalitzats.
Comment[ca@valencia]=Agafa continguts amb scripts personalitzats.
Comment[cs]=Stáhnout obsah pomocí vlastních skriptů.
Comment[da]=Henter indhold med brugerdefinerede scripts.
Comment[de]=Lädt Dateninhalte mit eigenen Skripten herunter
Comment[el]=Ανάκτηση περιεχομένων με προσαρμοσμένα σενάρια.
Comment[en_GB]=Fetch contents with custom scripts.
Comment[es]=Obtener contenidos con scripts personalizados.
Comment[et]=Sisu tõmbamine kohandatud skriptidega.
Comment[eu]=Edukiak deskargatzen ditu script pertsonalizatuekin.
Comment[fi]=Nouda sisältöjä mukautetuilla skripteillä.
Comment[fr]=Télécharge un contenu avec des scripts personnalisés.
Comment[ga]=Faigh ábhar le scripteanna saincheaptha.
Comment[gl]=Obtén contidos con scripts personalizados.
Comment[hr]=Dohvati sadržaj pomoću vlastitih skripti.
Comment[hu]=Letöltés szkripttel.
Comment[ia]=Reporta contentos con scripts personalisate.
Comment[it]=Scarica contenuti con script personalizzati.
Comment[ja]=使
Comment[kk]=Мазмұнын өзінің скрипттерінін көмегімен алу
Comment[km]=
Comment[ko]= .
Comment[lt]=Atsiųsti turinį naudojant savo scenarijus.
Comment[lv]=Ielādē saturu ar pielāgotiem skriptiem
Comment[ml]= ി
Comment[nb]=Hent innhold med selvvalgte skripter
Comment[nds]=Inholt mit egen Skripten halen
Comment[nl]=Inhoud ophalen met aangepaste scripts.
Comment[nn]=Hent innhald med vanlege skript.
Comment[pa]= ਿ
Comment[pl]=Pobiera treści z pomocą konfigurowanych skryptów.
Comment[pt]=Obtém os conteúdos com programas personalizados.
Comment[pt_BR]=Busca conteúdos com scripts personalizados.
Comment[ro]=Preluați conținut cu scripturi personalizate.
Comment[ru]=Получить содержимое используя сценарий
Comment[si]= .
Comment[sk]=Získanie obsahu pomocou vlastných skriptov.
Comment[sl]=Pridobite vsebino z uporabo skriptov po meri.
Comment[sr]=Добавља садржаје помоћу посебних скрипти.
Comment[sr@ijekavian]=Добавља садржаје помоћу посебних скрипти.
Comment[sr@ijekavianlatin]=Dobavlja sadržaje pomoću posebnih skripti.
Comment[sr@latin]=Dobavlja sadržaje pomoću posebnih skripti.
Comment[sv]=Hämta innehåll med egna skript.
Comment[tr]=Özel betiklerle içerik getir.
Comment[ug]=مەزمۇنغا ئېرىشىدىغان ئىختىيارىي قوليازما.
Comment[uk]=Отримайте вміст за допомогою нетипових скриптів.
Comment[x-test]=xxFetch contents with custom scripts.xx
Comment[zh_CN]=使
Comment[zh_TW]=使稿
# options for library loader
X-KDE-Library=kget_contentfetchfactory
X-KDE-KGet-plugintype=TransferFactory
X-KDE-KGet-rank=110
X-KDE-KGet-framework-version=1
X-KDE-PluginInfo-Author=Ningyu Shi
X-KDE-PluginInfo-Email=shiningyu@gmail.com
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Category=Service
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-PluginInfo-Name=kget_contentfetch_plugin

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kget_contentfetchfactory.rc"/>
<group name="UserScripts">
<entry name="UrlRegexpList" type="StringList" key="RegexpItems">
<label>List of the Regexp to match input URL</label>
<default>youtube.*watch</default>
</entry>
<entry name="PathList" type="StringList" key="PathItems">
<label>List of the available search engine URLs</label>
<code>
QStringList searchEngines;
searchEngines.append(KStandardDirs::locate("data", "kget/content_fetch_scripts/youtubedl/kget_youtubedl.py"));
</code>
<default code="true">searchEngines</default>
</entry>
<entry name="DescriptionList" type="StringList" key="DescriptionItems">
<label>List of descriptions for user scripts</label>
<default>A youtube flash video downloader</default>
</entry>
<entry name="EnableList" type="IntList" key="EnableItems">
<label>List of whether the script is enabled</label>
<default>1</default>
</entry>
</group>
</kcfg>

View file

@ -1,64 +0,0 @@
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_kget_contentfetchfactory
X-KDE-ParentComponents=kget_contentfetch_plugin
Name=Content Fetcher
Name[ar]=جالب المحتوى
Name[ast]=Content Fetcher
Name[bg]=ИзтеглянеСъдържание
Name[bs]=Dobavljač sadržaja
Name[ca]=Recollidor de continguts
Name[ca@valencia]=Recollidor de continguts
Name[cs]=Stahovač obsahu
Name[da]=Content Fetcher
Name[de]=Daten-Lader
Name[el]=Ανάκτηση περιεχομένου
Name[en_GB]=Content Fetcher
Name[es]=Content Fetcher
Name[et]=Sisutõmbaja
Name[eu]=Edukiaren eskuratzailea
Name[fi]=Sisältänoutaja
Name[fr]=Chercheur de contenu
Name[ga]=Content Fetcher
Name[gl]=Módulo de obteción de contidos
Name[hne]=
Name[hr]=Content Fetcher
Name[hu]=Letöltő
Name[ia]=Reportator de contento
Name[is]=Nær í innihald
Name[it]=Scaricatore di contenuti
Name[ja]=
Name[kk]=Мазмұнын алғышы
Name[km]=
Name[ko]=
Name[lt]=Turinio atsiuntėjas
Name[lv]=Satura ielādētājs
Name[ml]=
Name[nb]=Innholdshenter
Name[nds]=Inholthaler
Name[nl]=Inhoudophaler
Name[nn]=Innhaldshenting
Name[pa]=
Name[pl]=Pobieranie treści
Name[pt]=Módulo de Obtenção de Conteúdos
Name[pt_BR]=Capturador de conteúdo
Name[ro]=Preluator de conținut
Name[ru]=Получение содержимое
Name[si]=
Name[sk]=Sťahovač obsahu
Name[sl]=Pridobivanje vsebine
Name[sr]=Добављач садржаја
Name[sr@ijekavian]=Добављач садржаја
Name[sr@ijekavianlatin]=Dobavljač sadržaja
Name[sr@latin]=Dobavljač sadržaja
Name[sv]=Hämta innehåll
Name[th]=
Name[tr]=İçerik Getirici
Name[ug]=مەزمۇنغا ئېرىشكۈچ
Name[uk]=Засіб обробки вмісту
Name[x-test]=xxContent Fetcherxx
Name[zh_CN]=
Name[zh_TW]=

View file

@ -1,89 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#include "script.h"
#include "scriptdownloadengine.h"
#include "scriptconfigadaptor.h"
#include <QVariant>
#include <KDebug>
Script::Script(QObject* parent, const KUrl &source)
:QThread(parent), m_p_kgetcore(0), m_source(source)
{
kDebug(5002) << "One Script Newed.";
/*
Use 0 as parent here because of threading issue, comply to qt manual.
Adapted below:
" The child of a QObject must always be created in the thread where the
parent was created. This implies, among other things, that you should
never pass the QThread object (this) as the parent of an object created
in the thread (since the QThread object itself was created in another thread)."
See http://doc.trolltech.com/4.4/threads.html#qobject-reentrancy
*/
m_p_kgetcore = new ScriptDownloadEngine(0, m_source);
}
Script::~Script()
{
delete m_p_kgetcore;
delete m_p_action;
kDebug(5002) << "m_p_kgetcore & m_p_action is deleted!";
}
bool Script::setFile(const QString &filename)
{
m_fileName = filename;
return true;
}
void Script::run()
{
setPriority(QThread::LowPriority);
// use 0 as parent, see Constructor.
m_p_action = new Kross::Action(0, m_fileName); //"ContentFetchScript");
// quit the exec() loop after get finish/abort signal from script
connect(m_p_kgetcore, SIGNAL(finished()), this, SLOT(quit()));
connect(m_p_kgetcore, SIGNAL(aborted(QString)), this, SLOT(quit()));
// add transfer
connect(m_p_kgetcore, SIGNAL(newTransfer(QString,QString)),
this, SIGNAL(newTransfer(QString,QString)));
// update status signal/slot
connect(m_p_kgetcore, SIGNAL(percentUpdated(int)),
this, SIGNAL(percentUpdated(int)));
connect(m_p_kgetcore, SIGNAL(textStatusUpdated(QString)),
this, SIGNAL(textStatusUpdated(QString)));
connect(m_p_kgetcore, SIGNAL(finished()), this, SIGNAL(finished()));
connect(m_p_kgetcore, SIGNAL(aborted(QString)), this, SIGNAL(aborted(QString)));
// main entry point
connect(this, SIGNAL(startDownload(QObject*)),
m_p_kgetcore, SIGNAL(startDownload(QObject*)));
m_p_action->setFile(m_fileName);
// TODO add check
kDebug(5002) << "KGetCore Added to script at ThreadId " << QThread::currentThreadId();
m_p_action->addObject(m_p_kgetcore, "kgetcore",
Kross::ChildrenInterface::AutoConnectSignals);
m_p_action->trigger();
ScriptConfigAdaptor config;
emit startDownload(&config);
//m_p_action->callFunction("startDownload", QVariantList());
kDebug(5002) << "Script Finished!" << QThread::currentThreadId();
//delete m_p_kgetcore;
//delete m_p_action;
if (m_p_action->hadError())
{
kDebug(5002) << "Error:" << m_p_action->errorMessage() << m_p_action->errorTrace();
}
else
{
exec();
}
}

View file

@ -1,46 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#ifndef SCRIPT_H
#define SCRIPT_H
#include <QObject>
#include <QThread>
#include <QPointer>
#include <KUrl>
#include <kross/core/action.h>
class ScriptDownloadEngine;
class TransferGroup;
class Script: public QThread
{
Q_OBJECT
public:
Script(QObject* parent, const KUrl &source);
~Script();
bool setFile(const QString &filename);
signals:
void newTransfer(const QString &url, const QString &filename);
void startDownload(QObject* configadaptor);
void percentUpdated(int percent);
void textStatusUpdated(const QString &text);
void finished();
void aborted(const QString &error);
protected:
void run();
private:
QPointer<Kross::Action> m_p_action;
ScriptDownloadEngine *m_p_kgetcore;
KUrl m_source;
QString m_fileName;
};
#endif // SCRIPT_H

View file

@ -1,125 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#include "scriptconfigadaptor.h"
#include <QFileInfo>
#include <QString>
#include <KStandardDirs>
#include <KDebug>
bool ScriptConfigAdaptor::setFile(const QString &filename,
const QString &path)
{
if (!m_config)
{
if (!path.isEmpty())
{
QFileInfo info(path);
if (info.isDir() && info.exists())
{
// check for the ending slash
if (path.endsWith('/'))
{
m_config = new KConfig(path + filename);
}
else
{
m_config = new KConfig(path + '/' + filename);
}
return true;
}
else
{
return false;
}
}
else
{
QString default_path;
// put the config file in default user directory
// like ~/.kde4/share/app/kget/content_scrips_setting/
default_path = KStandardDirs::locateLocal("appdata", "contentfetch_scripts_setting/");
m_config = new KConfig(default_path + filename);
return true;
}
}
return false;
}
void ScriptConfigAdaptor::unsetFile()
{
delete m_config;
m_config = 0;
}
QVariant ScriptConfigAdaptor::read(const QString& group,
const QString& key,
const QVariant& defaultvalue)
{
m_group = m_config->group(group);
QVariant value;
switch(defaultvalue.type())
{
case QVariant::Int:
value = m_group.readEntry(key, defaultvalue.toInt());
break;
case QVariant::Double:
value = m_group.readEntry(key, defaultvalue.toDouble());
break;
case QVariant::StringList:
value = m_group.readEntry(key, defaultvalue.toStringList());
break;
case QVariant::List:
value = m_group.readEntry(key, defaultvalue.toList());
break;
default:
value = m_group.readEntry(key, defaultvalue.toString());
break;
};
return value;
}
void ScriptConfigAdaptor::write(const QString& group,
const QString& key,
const QVariant& value)
{
m_group = m_config->group(group);
switch(value.type())
{
case QVariant::Int:
m_group.writeEntry(key, value.toInt());
break;
case QVariant::Double:
m_group.writeEntry(key, value.toDouble());
break;
case QVariant::StringList:
m_group.writeEntry(key, value.toStringList());
break;
case QVariant::List:
m_group.writeEntry(key, value.toList());
break;
default:
m_group.writeEntry(key, value.toString());
break;
};
}
void ScriptConfigAdaptor::save()
{
m_config->sync();
}
void ScriptConfigAdaptor::reset()
{
m_config->markAsClean();
m_config->reparseConfiguration();
}

View file

@ -1,49 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#ifndef SCRIPT_CONFIGADAPTOR_H
#define SCRIPT_CONFIGADAPTOR_H
#include <QObject>
#include <QString>
#include <QVariant>
#include <kconfig.h>
#include <kconfiggroup.h>
class ScriptConfigAdaptor : public QObject
{
Q_OBJECT
public:
ScriptConfigAdaptor(QObject* parent = 0) : QObject(parent), m_config(0) {}
virtual ~ScriptConfigAdaptor()
{
delete m_config;
}
public slots:
bool setFile(const QString &filename, const QString &path = QString());
void unsetFile();
QVariant read(const QString &group, const QString &key,
const QVariant &defaultvalue = QVariant());
void write(const QString &group, const QString &key,
const QVariant &value);
void save();
/**
* Discard current setting, reread from disk file.
*
*/
void reset();
private:
KConfig* m_config;
KConfigGroup m_group;
};
#endif // SCRIPT_CONFIGADAPTOR_H

View file

@ -1,61 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#include "scriptdownloadengine.h"
#include "core/transfergroup.h"
#include <kdebug.h>
ScriptDownloadEngine::ScriptDownloadEngine(QObject *parent,
const KUrl &source)
: QObject(parent),
m_source_url(source.url())
{
}
void ScriptDownloadEngine::setSourceUrl(const QString &url)
{
m_source_url = url;
}
QString ScriptDownloadEngine::getSourceUrl() const
{
return m_source_url;
}
bool ScriptDownloadEngine::addTransfer(const QString &url,
const QString &filename)
{
kDebug(5002) << "Url" << url << " file " << filename << " from Script.";
// TODO: check url here?
emit newTransfer(url, filename);
kDebug(5002) << "Transfer" << url << " Added to KGet.";
return true;
}
void ScriptDownloadEngine::setPercent(int percent)
{
emit percentUpdated(percent);
}
void ScriptDownloadEngine::setTextStatus(const QString &text)
{
emit textStatusUpdated(text);
}
void ScriptDownloadEngine::finish()
{
emit finished();
}
void ScriptDownloadEngine::abort(const QString &error)
{
emit aborted(error);
}

View file

@ -1,47 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
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.
*/
#ifndef SCRIPT_DOWNLOAD_ENGINE_H
#define SCRIPT_DOWNLOAD_ENGINE_H
#include <QObject>
#include <QString>
#include <KUrl>
// forward declaration
class TransferGroup;
class Script;
class ScriptDownloadEngine: public QObject
{
Q_OBJECT
public:
ScriptDownloadEngine(QObject *parent, const KUrl &source);
~ScriptDownloadEngine(){}
void setSourceUrl(const QString &url);
signals:
void newTransfer(const QString &url, const QString &filename);
void startDownload(QObject* configadaptor);
void percentUpdated(int percent);
void textStatusUpdated(const QString &text);
void finished();
void aborted(const QString& error);
public slots:
QString getSourceUrl() const;
bool addTransfer(const QString &url,
const QString &filename = QString());
void setPercent(int percent);
void setTextStatus(const QString &text);
void finish();
void abort(const QString &error = QString());
private:
QString m_source_url;
};
#endif // SCRIPT_DOWNLOAD_ENGINE_H

View file

@ -1,4 +0,0 @@
install(FILES youtubedl/kget_youtubedl.py DESTINATION ${KDE4_DATA_INSTALL_DIR}/kget/content_fetch_scripts/youtubedl)
install(FILES youtubedl/kget_youtubedl_option.py DESTINATION ${KDE4_DATA_INSTALL_DIR}/kget/content_fetch_scripts/youtubedl)
install(FILES youtubedl/ui_youtube_option.py DESTINATION ${KDE4_DATA_INSTALL_DIR}/kget/content_fetch_scripts/youtubedl)
install(FILES youtubedl/youtube_option.ui DESTINATION ${KDE4_DATA_INSTALL_DIR}/kget/content_fetch_scripts/youtubedl)

View file

@ -1,267 +0,0 @@
#!/usr/bin/env python
#
# This file is part of the KDE project
#
# Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
# 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.
# Copyright (c) 2006-2008 Ricardo Garcia Gonzalez
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
#
import getpass
import os
import re
import string
import sys
import urllib
import urllib2
# Global constants
const_video_url_str = 'http://www.youtube.com/watch?v=%s'
const_video_url_re = re.compile(r'^((?:http://)?(?:\w+\.)?youtube\.com/(?:(?:v/)|(?:(?:watch(?:\.php)?)?\?(?:.+&)?v=)))?([0-9A-Za-z_-]+)(?(1).+)?$')
const_video_url_format_suffix = '&fmt=%s'
const_best_quality_format = 18
const_login_url_str = 'http://www.youtube.com/login?next=/watch%%3Fv%%3D%s'
const_login_post_str = 'current_form=loginForm&next=%%2Fwatch%%3Fv%%3D%s&username=%s&password=%s&action_login=Log+In'
const_bad_login_re = re.compile(r'(?i)<form[^>]* name="loginForm"')
const_age_url_str = 'http://www.youtube.com/verify_age?next_url=/watch%%3Fv%%3D%s'
const_age_post_str = 'next_url=%%2Fwatch%%3Fv%%3D%s&action_confirm=Confirm'
const_url_t_param_re = re.compile(r', "t": "([^"]+)"')
const_video_url_real_str = 'http://www.youtube.com/get_video?video_id=%s&t=%s'
const_video_title_re = re.compile(r'<title>YouTube - ([^<]*)</title>', re.M | re.I)
global_error = False
# Print error message, followed by standard advice information, and then exit
def exit_with_error(error_text):
global global_error
import kgetcore
kgetcore.abort('Error: ' + error_text)
global_error = True
# Wrapper to create custom requests with typical headers
def request_create(url, extra_headers, post_data):
retval = urllib2.Request(url)
if post_data is not None:
retval.add_data(post_data)
# Try to mimic Firefox, at least a little bit
retval.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
retval.add_header('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')
retval.add_header('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5')
retval.add_header('Accept-Language', 'en-us,en;q=0.5')
if extra_headers is not None:
for header in extra_headers:
retval.add_header(header[0], header[1])
return retval
# Perform a request, process headers and return response
def perform_request(url, headers=None, data=None):
request = request_create(url, headers, data)
response = urllib2.urlopen(request)
return response
# Conditional print
def cond_print(str):
import kgetcore
kgetcore.setTextStatus(str)
# Title string normalization
def title_string_norm(title):
title = ''.join((x in string.ascii_letters or x in string.digits) and x or ' ' for x in title)
title = '_'.join(title.split())
title = title.lower()
return title
# Generic download step
def download_step(return_data_flag, step_title, step_error, url, post_data=None):
try:
cond_print('%s... ' % step_title)
data = perform_request(url, data=post_data).read()
cond_print('%s... Done.' % step_title)
if return_data_flag:
return data
return None
except (urllib2.URLError, ValueError, httplib.HTTPException, TypeError, socket.error):
cond_print('%s... Failed.' % step_title )
exit_with_error(step_error)
# Generic extract step
def extract_step(step_title, step_error, regexp, data):
cond_print('%s... ' % step_title)
match = regexp.search(data)
if match is None:
cond_print('%s... Failed.' % step_title )
exit_with_error(step_error)
extracted_data = match.group(1)
cond_print('%s... Done.' % step_title)
return extracted_data
class YoutubeDlOption:
def __init__(self, kconfig):
self.parser = kconfig
self.parser.setFile('kget_youtubedl.rc')
def parse(self):
self.use_literal = bool(self.parser.read('FileSetting', 'UseLiteralName', 0))
if self.parser.read("FileSetting", "Quality", 1) == 0:
# index 0 of the combobox is best quality
self.best_quality = True
else:
self.best_quality = False
self.enable_login = bool(self.parser.read('LoginInfo', 'Enabled', 0))
self.username = self.parser.read('LoginInfo', 'Username', 'Nobody')
self.password = self.parser.read('LoginInfo', 'Password', 'passwd')
self.use_netrc = bool(self.parser.read('LoginInfo', 'UseNetrc', 0))
def startDownload(kconfig):
global global_error
import kgetcore
# read settings
option = YoutubeDlOption(kconfig)
option.parse()
# Verify video URL format and convert to "standard" format
video_url_cmdl = kgetcore.getSourceUrl()
video_url_mo = const_video_url_re.match(video_url_cmdl)
if video_url_mo is None:
video_url_mo = const_video_url_re.match(urllib.unquote(video_url_cmdl))
if video_url_mo is None:
exit_with_error('URL does not seem to be a youtube video URL. If it is, report a bug.')
return
video_url_id = video_url_mo.group(2)
video_url = const_video_url_str % video_url_id
video_format = None
if option.best_quality:
video_format = const_best_quality_format
video_extension = '.mp4'
else:
video_extension = '.flv'
if video_format is not None:
video_url = '%s%s' % (video_url, const_video_url_format_suffix % video_format)
# Get account information if any
account_username = None
account_password = None
if option.enable_login:
if option.use_netrc:
try:
info = netrc.netrc().authenticators('youtube')
if info is None:
exit_with_error('no authenticators for machine youtube.')
return
account_username = info[0]
account_password = info[2]
except IOError:
exit_with_error('unable to read .netrc file.')
return
except netrc.NetrcParseError:
exit_with_error('unable to parse .netrc file.')
return
else:
# TODO: check
account_username = option.username
account_password = option.password
# Install cookie and proxy handlers
urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()))
urllib2.install_opener(urllib2.build_opener(urllib2.HTTPCookieProcessor()))
# Log in and confirm age if needed
if account_username is not None:
kgetcore.setTextStatus('Logging in...')
url = const_login_url_str % video_url_id
post = const_login_post_str % (video_url_id, account_username, account_password)
reply_page = download_step(True, 'Logging in', 'unable to log in', url, post)
if global_error:
return
if const_bad_login_re.search(reply_page) is not None:
exit_with_error('unable to log in')
return
url = const_age_url_str % video_url_id
post = const_age_post_str % video_url_id
download_step(False, 'Confirming age', 'unable to confirm age', url, post)
if global_error:
return
# Install cookie and proxy handlers
urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()))
urllib2.install_opener(urllib2.build_opener(urllib2.HTTPCookieProcessor()))
# Retrieve video webpage
video_webpage = download_step(True, 'Retrieving video webpage', 'Unable to retrieve video webpage', video_url)
if global_error:
return
# Extract video title
video_title = extract_step('Extracting video title', 'Unable to extract video title', const_video_title_re, video_webpage)
if global_error:
return
# Extract needed video URL parameters
video_url_t_param = extract_step('Extracting URL "t" parameter', 'Unable to extract URL "t" parameter', const_url_t_param_re, video_webpage)
if global_error:
return
video_url_real = const_video_url_real_str % (video_url_id, video_url_t_param)
if video_format is not None:
video_url_real = '%s%s' % (video_url_real, const_video_url_format_suffix % video_format)
# Rebuild filename
if option.use_literal:
prefix = title_string_touch(video_title)
video_filename = '%s-%s%s' % (prefix, video_url_id, video_extension)
else:
prefix = title_string_norm(video_title)
video_filename = '%s%s' % (prefix, video_extension)
#video_filename = '%s%s' % (video_url_id, video_extension)
# Check name
if not video_filename.lower().endswith(video_extension):
kgetcore.setTextStatus('Warning: video file name does not end in %s\n' % video_extension)
# Add to kget
kgetcore.addTransfer(video_url_real, video_filename)
kgetcore.finish()
youtube_option = 0
def configureScript(widget, kconfig):
from kget_youtubedl_option import YoutubeDlOptionWidget
global youtube_option
youtube_option = YoutubeDlOptionWidget(kconfig)
widget.setWidget(youtube_option)
def configurationAccepted(widget, kconfig):
from kget_youtubedl_option import YoutubeDlOptionWidget
global youtube_option
youtube_option.saveSetting()

View file

@ -1,55 +0,0 @@
# This file is part of the KDE project
#
# Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
# 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.
from ui_youtube_option import Ui_YoutubeDlOption
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class YoutubeDlOptionWidget(QWidget):
def __init__(self, kconfig):
QWidget.__init__(self)
self.ui = Ui_YoutubeDlOption()
self.ui.setupUi(self)
self.parser = kconfig
self.cfgfile = 'kget_youtubedl.rc'
self.loadSetting()
self.connect(self.ui.useNetrcCheck, SIGNAL("stateChanged(int)"), self, SLOT("slotUseNetrcEnabled(int)"))
def loadSetting(self):
self.parser.setFile(self.cfgfile)
self.ui.fileNameComboBox.setCurrentIndex(self.parser.read('FileSetting', 'UseLiteralName', 0))
self.ui.qualityComboBox.setCurrentIndex(self.parser.read('FileSetting', 'Quality', 0))
self.ui.loginGroupBox.setChecked(bool(self.parser.read('LoginInfo', 'Enabled', 0)))
self.ui.usernameEdit.setText(self.parser.read('LoginInfo', 'Username', 'Nobody'))
self.ui.passwordEdit.setText(self.parser.read('LoginInfo', 'Password', 'passwd'))
self.ui.useNetrcCheck.setCheckState(Qt.CheckState(self.parser.read('LoginInfo', 'UseNetrc', 0)))
if self.ui.useNetrcCheck.checkState() == Qt.Checked:
self.enableUserPass(False)
def saveSetting(self):
self.parser.write('FileSetting', 'UseLiteralName', self.ui.fileNameComboBox.currentIndex())
self.parser.write('FileSetting', 'Quality', self.ui.qualityComboBox.currentIndex())
self.parser.write('LoginInfo', 'Enabled', int(self.ui.loginGroupBox.isChecked()))
# kross seems not directly support Qt.QString, use python string instead
self.parser.write('LoginInfo', 'Username', str(self.ui.usernameEdit.text()))
self.parser.write('LoginInfo', 'Password', str(self.ui.passwordEdit.text()))
self.parser.write('LoginInfo', 'UseNetrc', int(self.ui.useNetrcCheck.checkState()))
def enableUserPass(self, state):
self.ui.usernameLabel.setEnabled(state)
self.ui.usernameEdit.setEnabled(state)
self.ui.passwordLabel.setEnabled(state)
self.ui.passwordEdit.setEnabled(state)
# slot
@pyqtSignature("int")
def slotUseNetrcEnabled(self, state):
if state == int(Qt.Checked):
self.enableUserPass(False)
else:
self.enableUserPass(True)

View file

@ -1,87 +0,0 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'youtube_option.ui'
#
# Created: Tue Aug 5 22:51:51 2008
# by: PyQt4 UI code generator 4.4.3-snapshot-20080804
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_YoutubeDlOption(object):
def setupUi(self, YoutubeDlOption):
YoutubeDlOption.setObjectName("YoutubeDlOption")
YoutubeDlOption.resize(395, 349)
self.verticalLayout = QtGui.QVBoxLayout(YoutubeDlOption)
self.verticalLayout.setObjectName("verticalLayout")
self.fileSettingGroupBox = QtGui.QGroupBox(YoutubeDlOption)
self.fileSettingGroupBox.setObjectName("fileSettingGroupBox")
self.formLayout_3 = QtGui.QFormLayout(self.fileSettingGroupBox)
self.formLayout_3.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout_3.setObjectName("formLayout_3")
self.fileNameLabel = QtGui.QLabel(self.fileSettingGroupBox)
self.fileNameLabel.setObjectName("fileNameLabel")
self.formLayout_3.setWidget(0, QtGui.QFormLayout.LabelRole, self.fileNameLabel)
self.fileNameComboBox = QtGui.QComboBox(self.fileSettingGroupBox)
self.fileNameComboBox.setObjectName("fileNameComboBox")
self.fileNameComboBox.addItem(QtCore.QString())
self.fileNameComboBox.addItem(QtCore.QString())
self.formLayout_3.setWidget(0, QtGui.QFormLayout.FieldRole, self.fileNameComboBox)
self.qualityLabel = QtGui.QLabel(self.fileSettingGroupBox)
self.qualityLabel.setObjectName("qualityLabel")
self.formLayout_3.setWidget(1, QtGui.QFormLayout.LabelRole, self.qualityLabel)
self.qualityComboBox = QtGui.QComboBox(self.fileSettingGroupBox)
self.qualityComboBox.setObjectName("qualityComboBox")
self.qualityComboBox.addItem(QtCore.QString())
self.qualityComboBox.addItem(QtCore.QString())
self.formLayout_3.setWidget(1, QtGui.QFormLayout.FieldRole, self.qualityComboBox)
self.verticalLayout.addWidget(self.fileSettingGroupBox)
self.loginGroupBox = QtGui.QGroupBox(YoutubeDlOption)
self.loginGroupBox.setCheckable(True)
self.loginGroupBox.setChecked(False)
self.loginGroupBox.setObjectName("loginGroupBox")
self.verticalLayout_2 = QtGui.QVBoxLayout(self.loginGroupBox)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.formLayout = QtGui.QFormLayout()
self.formLayout.setObjectName("formLayout")
self.passwordLabel = QtGui.QLabel(self.loginGroupBox)
self.passwordLabel.setObjectName("passwordLabel")
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.passwordLabel)
self.passwordEdit = QtGui.QLineEdit(self.loginGroupBox)
self.passwordEdit.setEchoMode(QtGui.QLineEdit.Password)
self.passwordEdit.setObjectName("passwordEdit")
self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.passwordEdit)
self.usernameLabel = QtGui.QLabel(self.loginGroupBox)
self.usernameLabel.setObjectName("usernameLabel")
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.usernameLabel)
self.usernameEdit = QtGui.QLineEdit(self.loginGroupBox)
self.usernameEdit.setObjectName("usernameEdit")
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.usernameEdit)
self.verticalLayout_2.addLayout(self.formLayout)
self.useNetrcCheck = QtGui.QCheckBox(self.loginGroupBox)
self.useNetrcCheck.setObjectName("useNetrcCheck")
self.verticalLayout_2.addWidget(self.useNetrcCheck)
self.verticalLayout.addWidget(self.loginGroupBox)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.retranslateUi(YoutubeDlOption)
QtCore.QMetaObject.connectSlotsByName(YoutubeDlOption)
def retranslateUi(self, YoutubeDlOption):
YoutubeDlOption.setWindowTitle(QtGui.QApplication.translate("YoutubeDlOption", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.fileSettingGroupBox.setTitle(QtGui.QApplication.translate("YoutubeDlOption", "File-Settings", None, QtGui.QApplication.UnicodeUTF8))
self.fileNameLabel.setText(QtGui.QApplication.translate("YoutubeDlOption", "Filename:", None, QtGui.QApplication.UnicodeUTF8))
self.fileNameComboBox.setItemText(0, QtGui.QApplication.translate("YoutubeDlOption", "Use normalized name", None, QtGui.QApplication.UnicodeUTF8))
self.fileNameComboBox.setItemText(1, QtGui.QApplication.translate("YoutubeDlOption", "Use literal name", None, QtGui.QApplication.UnicodeUTF8))
self.qualityLabel.setText(QtGui.QApplication.translate("YoutubeDlOption", "Quality:", None, QtGui.QApplication.UnicodeUTF8))
self.qualityComboBox.setItemText(0, QtGui.QApplication.translate("YoutubeDlOption", "Best quality (.mp4)", None, QtGui.QApplication.UnicodeUTF8))
self.qualityComboBox.setItemText(1, QtGui.QApplication.translate("YoutubeDlOption", "Normal quality (.flv)", None, QtGui.QApplication.UnicodeUTF8))
self.loginGroupBox.setToolTip(QtGui.QApplication.translate("YoutubeDlOption", "Provide login info of your youtube account in order to access restricted media.", None, QtGui.QApplication.UnicodeUTF8))
self.loginGroupBox.setTitle(QtGui.QApplication.translate("YoutubeDlOption", "Login Info", None, QtGui.QApplication.UnicodeUTF8))
self.passwordLabel.setText(QtGui.QApplication.translate("YoutubeDlOption", "Password:", None, QtGui.QApplication.UnicodeUTF8))
self.usernameLabel.setText(QtGui.QApplication.translate("YoutubeDlOption", "Username:", None, QtGui.QApplication.UnicodeUTF8))
self.useNetrcCheck.setToolTip(QtGui.QApplication.translate("YoutubeDlOption", ".netrc must have a hostname called \'youtube\'.", None, QtGui.QApplication.UnicodeUTF8))
self.useNetrcCheck.setText(QtGui.QApplication.translate("YoutubeDlOption", "User .netrc file", None, QtGui.QApplication.UnicodeUTF8))

View file

@ -1,152 +0,0 @@
<ui version="4.0" >
<class>YoutubeDlOption</class>
<widget class="QWidget" name="YoutubeDlOption" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>349</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QGroupBox" name="fileSettingGroupBox" >
<property name="title" >
<string>File Settings</string>
</property>
<layout class="QFormLayout" name="formLayout_3" >
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="fileNameLabel" >
<property name="text" >
<string>Filename:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KComboBox" name="fileNameComboBox" >
<item>
<property name="text" >
<string>Use Normalized Name</string>
</property>
</item>
<item>
<property name="text" >
<string>Use Literal Name</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="qualityLabel" >
<property name="text" >
<string>Quality:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KComboBox" name="qualityComboBox" >
<item>
<property name="text" >
<string>Best Quality (.mp4)</string>
</property>
</item>
<item>
<property name="text" >
<string>Normal Quality (.flv)</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="loginGroupBox" >
<property name="toolTip" >
<string>Provide login info of your YouTube account in order to access restricted media.</string>
</property>
<property name="title" >
<string>Login Info</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QFormLayout" name="formLayout" >
<item row="2" column="0" >
<widget class="QLabel" name="passwordLabel" >
<property name="text" >
<string>Password:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="passwordEdit" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="usernameLabel" >
<property name="text" >
<string>Username:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="usernameEdit" />
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="useNetrcCheck" >
<property name="toolTip" >
<string>.netrc must have a hostname called 'youtube'.</string>
</property>
<property name="text" >
<string>User .netrc file</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>