Skip to content

Commit

Permalink
Procisteni kodui, GUI a CLI verze zvlast
Browse files Browse the repository at this point in the history
  • Loading branch information
ibv committed Apr 24, 2019
1 parent 4fda98f commit bf09dea
Show file tree
Hide file tree
Showing 9 changed files with 283 additions and 263 deletions.
4 changes: 2 additions & 2 deletions Source/Base/uDASHDownloader.pas
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ TDASHDownloader = class(TCommonDownloader)
implementation

uses
SynaUtil, strutils,
uLanguages, uMessages, uFunctions;
strutils,
uLanguages, uMessages;



Expand Down
10 changes: 5 additions & 5 deletions Source/Base/uHLSDownloader.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface
{$ELSE}
LCLIntf, LCLType, LMessages,
{$ENDIF}
uPCRE, uXml, uHttp, uCompatibility, HttpSend, blcksock,
uPCRE, uXml, uHttp, HttpSend, blcksock,
uDownloader, uCommonDownloader, uDASHDownloader;

type
Expand Down Expand Up @@ -96,8 +96,8 @@ THLSDownloader = class(TCommonDownloader)
implementation

uses
SynaUtil, SynaCode,
uLanguages, uMessages, uFunctions, uFiles

uLanguages, uMessages, uFiles

;

Expand Down Expand Up @@ -140,7 +140,7 @@ function THLSDownloader.GetContentUrl: string;
begin
Result := Format('HLS "%s"', [MovieURL]);
//--
if Options.ReadProviderOptionDef(Provider, OPTION_CT_DASH_SUPPORT, false) then
if (LowerCase(Provider)='ceskatelevize.cz') and Options.ReadProviderOptionDef(Provider, OPTION_CT_DASH_SUPPORT, false) then
begin
Result := Format('DASH "%s"', [MovieURL]);
end;
Expand Down Expand Up @@ -299,7 +299,7 @@ function THLSDownloader.Download: boolean;
inherited Download;
Result := False;

if Options.ReadProviderOptionDef('CeskaTelevize.cz', 'dash_support', false) then
if (LowerCase(Provider)='ceskatelevize.cz') and Options.ReadProviderOptionDef('CeskaTelevize.cz', 'dash_support', false) then
begin
result:=DownloadDASH;
exit;
Expand Down
6 changes: 3 additions & 3 deletions Source/Common/uMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ implementation
FileCtrl,
{$ENDIF}
uSetup,
uCompatibility,

{$IFDEF SETUP_GUI}
{$IFDEF GUI_WINAPI}
guiSetupWINAPI,
Expand All @@ -65,8 +65,8 @@ implementation
uConsoleApp,
{$ENDIF}
{$IFDEF GUI}
guiConsts,
guiFunctions,


{$IFDEF GUI_WINAPI}
guiMainWINAPI,
{$ELSE}
Expand Down
22 changes: 9 additions & 13 deletions Source/Downloaders/downMarkiza.pas
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ TDownloader_Markiza = class(THLSDownloader)


const
OPTION_CT_MAXBITRATE {$IFDEF MINIMIZESIZE} : string {$ENDIF} = 'max_bitrate';
OPTION_CT_MAXBITRATE_DEFAULT = 0;
OPTION_MAXBITRATE {$IFDEF MINIMIZESIZE} : string {$ENDIF} = 'max_bitrate';
OPTION_MAXBITRATE_DEFAULT = 0;

implementation

Expand All @@ -123,13 +123,9 @@ implementation
URLREGEXP_AFTER_ID = '';

const
///REGEXP_PLAYLIST_INFO = '\bgetPlaylistUrl\s*\(\s*\[\s*\{\s*"type"\s*:\s*"(?P<TYP>.+?)"\s*,\s*"id"\s*:\s*"(?P<ID>\d+)"';
///REGEXP_PLAYLIST_URL = '"url"\s*:\s*"(?P<URL>https?:.+?)"';
REGEXP_STREAM_URL = 'var (:bitrates|src)\s*=(?:.|\s)+?:\s"(?P<URLS>.+?)"';
///REGEXP_STREAM_TITLE = '"playlist"\s*:\s*\[.*?"title"\s*:\s*"(?P<TITLE>.*?)"';
REGEXP_STREAM_TITLE = 'mb-5(?:.|\s)+?"e-title">(?P<TITLE>.+?)</h3>';
///REGEXP_STREAM_TITLE_BETTER = '"playlist"\s*:\s*\[.*?"gemius"\s*:\s*\{[^}]*"NAZEV"\s*:\s*"(?P<TITLE>.*?)"';
///REGEXP_IFRAME_URL = '<(?:iframe\b[^>]*\ssrc|a\b[^>]*\shref)="(?P<URL>(?:https?://[^/]+)?/ivysilani/.+?)"';
///REGEXP_STREAM_TITLE = 'mb-5(?:.|\s)+?"e-title">(?P<TITLE>.+?)</h3>';
REGEXP_STREAM_TITLE = 'videoTitle:\s*"(?P<TITLE>.+?)",';
REGEXP_IFRAME_URL = '<iframe\s+src="(?P<URL>(.+?))" style';
REGEXP_STREAM_TITLEFROMPAGE = REGEXP_TITLE_TITLE;

Expand Down Expand Up @@ -206,9 +202,9 @@ function TDownloader_Markiza.AfterPrepareFromPage(var Page: string; PageXml: TXm
Result := False;

ParseUrl(GetMovieInfoUrl, Prot, User, Pass, Host, Port, Part, Para);
if not GetRegExpVar(StreamTitleRegExp, Page, 'TITLE', Title) then
{if not GetRegExpVar(StreamTitleRegExp, Page, 'TITLE', Title) then
SetLastErrorMsg(ERR_FAILED_TO_LOCATE_MEDIA_TITLE)
else if not GetRegExpVar(IFrameUrlRegExp, Page, 'URL', PlaylistUrlPage) then
else} if not GetRegExpVar(IFrameUrlRegExp, Page, 'URL', PlaylistUrlPage) then
if PlaylistUrlPage <> '' then
SetLastErrorMsg(Format(ERR_SERVER_ERROR, [PlaylistUrlPage]))
else
Expand All @@ -224,12 +220,12 @@ function TDownloader_Markiza.AfterPrepareFromPage(var Page: string; PageXml: TXm
{$ENDIF}
else
begin
if Title = '' then
if not GetRegExpVar(StreamTitleFromPageRegExp, PlayList, 'TITLE', Title) then
SetLastErrorMsg(ERR_FAILED_TO_LOCATE_MEDIA_TITLE);
Title := trim(AnsiEncodedUtf8ToString( {$IFDEF UNICODE} AnsiString {$ENDIF} (JSDecode(Title))));
///if GetRegExpVar(StreamTitle2RegExp, Playlist, 'TITLE', Title2) and (Title2 <> '') then
/// Title := AnsiEncodedUtf8ToString( {$IFDEF UNICODE} AnsiString {$ENDIF} (JSDecode(Title2)));
if Title = '' then
if not GetRegExpVar(StreamTitleFromPageRegExp, Page, 'TITLE', Title) then
SetLastErrorMsg(ERR_FAILED_TO_LOCATE_MEDIA_TITLE);
{$IFDEF MULTIDOWNLOADS}
for i := 0 to Pred(Length(Urls)) do
begin
Expand Down
22 changes: 16 additions & 6 deletions Source/GUI/VCL/guiOptionsVCL.dfm
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
object FormOptions: TFormOptions
Left = 284
Top = 158
Width = 551
Height = 465
Caption = 'Options'
ClientHeight = 426
ClientWidth = 535
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Expand All @@ -15,6 +15,9 @@ object FormOptions: TFormOptions
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
DesignSize = (
535
426)
PixelsPerInch = 96
TextHeight = 13
object BtnOK: TButton
Expand Down Expand Up @@ -44,11 +47,14 @@ object FormOptions: TFormOptions
Top = 0
Width = 543
Height = 389
ActivePage = TabDownloadOptions
ActivePage = TabMain
Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 2
object TabMain: TTabSheet
Caption = 'Main settings'
DesignSize = (
535
361)
object LabelLanguage: TLabel
Left = 8
Top = 180
Expand Down Expand Up @@ -149,6 +155,9 @@ object FormOptions: TFormOptions
object TabDownloadOptions: TTabSheet
Caption = 'Download settings'
ImageIndex = 1
DesignSize = (
535
361)
object LabelOverwriteMode: TLabel
Left = 8
Top = 188
Expand Down Expand Up @@ -205,7 +214,6 @@ object FormOptions: TFormOptions
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
ItemHeight = 13
TabOrder = 9
end
object EditDownloadDir: TEdit
Expand All @@ -232,7 +240,6 @@ object FormOptions: TFormOptions
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
ItemHeight = 13
TabOrder = 11
OnChange = ComboConverterChange
end
Expand Down Expand Up @@ -287,7 +294,6 @@ object FormOptions: TFormOptions
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
ItemHeight = 13
TabOrder = 8
end
object CheckAutoDeleteFinishedDownloads: TCheckBox
Expand All @@ -303,6 +309,9 @@ object FormOptions: TFormOptions
object TabNetworkOptions: TTabSheet
Caption = 'Network settings'
ImageIndex = 2
DesignSize = (
535
361)
object LabelProxyHost: TLabel
Left = 8
Top = 40
Expand Down Expand Up @@ -409,6 +418,7 @@ object FormOptions: TFormOptions
object actCancel: TAction
Caption = '&Cancel'
ShortCut = 27
OnExecute = actCancelExecute
end
object actDownloadDir: TAction
Caption = '...'
Expand Down
9 changes: 8 additions & 1 deletion Source/GUI/VCL/guiOptionsVCL.pas
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ interface
{$ENDIF}
uLanguages, uMessages, uOptions, uDialogs, uFunctions, guiFunctions,
uDownloadClassifier, uDownloader, guiOptions,
guiDownloaderOptions, guiOptionsVCL_Downloader, guiOptionsVCL_CommonDownloader;
guiDownloaderOptions, guiOptionsVCL_Downloader, guiOptionsVCL_CommonDownloader,
System.Actions;

type
TFormOptions = class(TForm)
Expand Down Expand Up @@ -112,6 +113,7 @@ TFormOptions = class(TForm)
procedure actStartMenuShortcutExecute(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ListDownloaderOptionsClick(Sender: TObject);
procedure actCancelExecute(Sender: TObject);
private
fLoading: boolean;
fOptions: TYTDOptionsGUI;
Expand Down Expand Up @@ -357,6 +359,11 @@ procedure TFormOptions.ComboConverterChange(Sender: TObject);
{$ENDIF}
end;

procedure TFormOptions.actCancelExecute(Sender: TObject);
begin
Close;
end;

procedure TFormOptions.actDesktopShortcutExecute(Sender: TObject);
begin
CreateShortcut(APPLICATION_SHORTCUT, '', CSIDL_DESKTOPDIRECTORY, ParamStr(0), ''{SETUP_PARAM_GUI});
Expand Down
5 changes: 4 additions & 1 deletion Source/YTD.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ uses
uHLSDownloader in 'Base\uHLSDownloader.pas',
uHLSDirectDownloader in 'Base\uHLSDirectDownloader.pas',
uScriptedDownloader in 'Base\uScriptedDownloader.pas',
uDASHDownloader in 'Base\uDASHDownloader.pas',
// Command Line Version
{$IFDEF CLI}
uYTD in 'CLI\uYTD.pas',
Expand Down Expand Up @@ -123,10 +124,11 @@ uses
guiOptionsVCL in 'GUI\VCL\guiOptionsVCL.pas' {FormOptions},
guiOptionsVCL_Downloader in 'GUI\VCL\Downloaders\guiOptionsVCL_Downloader.pas' {FrameDownloaderOptionsPageVCL: TFrame},
guiOptionsVCL_CommonDownloader in 'GUI\VCL\Downloaders\guiOptionsVCL_CommonDownloader.pas' {FrameDownloaderOptionsPageCommonVCL: TFrame},
//guiOptionsVCL_CT in 'GUI\VCL\Downloaders\guiOptionsVCL_CT.pas' {FrameDownloaderOptionsPage_CT: TFrame},
guiOptionsVCL_CT in 'GUI\VCL\Downloaders\guiOptionsVCL_CT.pas' {FrameDownloaderOptionsPage_CT: TFrame},
guiOptionsVCL_EuroSeptik in 'GUI\VCL\Downloaders\guiOptionsVCL_EuroSeptik.pas' {FrameDownloaderOptionsPage_EuroSeptik: TFrame},
guiOptionsVCL_Joj in 'GUI\VCL\Downloaders\guiOptionsVCL_Joj.pas' {FrameDownloaderOptionsPage_Joj: TFrame},
guiOptionsVCL_YouTube in 'GUI\VCL\Downloaders\guiOptionsVCL_YouTube.pas' {FrameDownloaderOptionsPage_YouTube: TFrame},
guiOptionsVCL_Prima in 'GUI\VCL\Downloaders\guiOptionsVCL_Prima.pas' {FrameDownloaderOptionsPage_Prima: TFrame},
{$IFDEF CONVERTERS}
guiConverterVCL in 'GUI\VCL\guiConverterVCL.pas' {FormSelectConverter},
{$ENDIF}
Expand Down Expand Up @@ -295,6 +297,7 @@ uses
downPracticalMethod in 'Downloaders\downPracticalMethod.pas',
downPrahovaHD in 'Downloaders\downPrahovaHD.pas',
downPrazdninyVTelci in 'Downloaders\downPrazdninyVTelci.pas',
downPrima in 'Downloaders\downPrima.pas',
downProglas in 'Downloaders\downProglas.pas',
downProstoPleer in 'Downloaders\downProstoPleer.pas',
downPublicTV in 'Downloaders\downPublicTV.pas',
Expand Down
Loading

0 comments on commit bf09dea

Please sign in to comment.