Skip to content

Commit

Permalink
Merge pull request #14 from oleksis/master
Browse files Browse the repository at this point in the history
Version 0.4.1
  • Loading branch information
oleksis authored Dec 3, 2020
2 parents b1309fc + c1e5694 commit 88107a7
Show file tree
Hide file tree
Showing 24 changed files with 547 additions and 253 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.mp3
*.mp4
*.flv
.vscode
build
dist
*.spec
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ This repository contains code for a youtube-dl GUI written in PyQt. It is based

## Requirements:

- Python >= v3.x
- PyQt5
- [youtube_dl](https://github.com/ytdl-org/youtube-dl)
- Python >= v3.x
- [FFmpeg](https://ffmpeg.org/download.html) (optional, to postprocess video files)

### Requirement for build Binaries/Executables

- [PyInstaller](https://www.pyinstaller.org/)

## Features:

Expand All @@ -34,13 +39,13 @@ This program is still in beta so if you encounter any bugs feel free to report t

## TODO:

- Fix Convert (main:MainWindow.convert_file)
- integrate save state
- Allow pause/resume functionality
- integrate save state
- ~~integrate post processing options~~
- ~~integrate batch add feature~~
- ~~integrate Queue to make it stable~~
- ~~Change for PyInstaller: setup.py - _see Windows_~~
- ~~Fix Convert (main:MainWindow.convert_file)~~

## Windows:

Expand All @@ -52,6 +57,9 @@ python setup.py pyinstaller

This will result in a **dist** and **build** directory. Simply go to the **dist** directory and you will get a ```youtube-dl-gui.exe``` file and some other files. That ```youtube-dl-gui.exe``` file is a standalone executable which can be run simply by double clicking it. You can distribute that file to your friend.

### Download
Can dowload the latest version from [Releases](https://github.com/yasoob/youtube-dl-GUI/releases/latest)

## License:

This project is released under the MIT license. See the included license file.
19 changes: 9 additions & 10 deletions Threads/PostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ def __init__(self, outpath, downloader=None, preferedformat=None):

def run(self, information):
path = information['filepath']
self.outpath = os.path.join(self.outpath, os.path.split(path)[-1])
file_name = os.path.split(path)[-1]
self.outpath = os.path.join(self.outpath, file_name)

if information['ext'] == self._preferedformat:
return True, information

prefix, sep, ext = path.rpartition('.')

# print(path)
# print(self.outpath)
# print(self._preferedformat)
# print(prefix + sep + self._preferedformat)
# print("\n")
prefix, sep, ext = self.outpath.rpartition('.')
self.outpath = prefix + sep + self._preferedformat

self.run_ffmpeg(path, self.outpath, [])
information['filepath'] = self.outpath
Expand All @@ -41,7 +38,7 @@ def to_screen(self, e):
class PostProcessorSignals(QtCore.QObject):
"Define the signals available from a running postprocessor thread"

statusSignal = QtCore.pyqtSignal(str)
statusBar_Signal = QtCore.pyqtSignal(str)
list_Signal = QtCore.pyqtSignal([list])
row_Signal = QtCore.pyqtSignal()
finished = QtCore.pyqtSignal()
Expand Down Expand Up @@ -82,8 +79,9 @@ def run(self):
self.bytes,
self.eta,
self.speed,
'Converting'
'Converting...'
])
self.signals.statusBar_Signal.emit('Converting...')
self.convert()
self.signals.list_Signal.emit([
self.local_rowcount,
Expand All @@ -93,6 +91,7 @@ def run(self):
self.speed,
'Finished'
])
self.signals.statusBar_Signal.emit('Done!')

def format_bytes(self, bytes):
if bytes is None:
Expand Down
2 changes: 1 addition & 1 deletion UI/AboutDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def setupUi(self, Dialog):
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "About"))
self.label_2.setText(_translate("Dialog", "<html><head/><body><p>Version: 0.4.0</p></body></html>"))
self.label_2.setText(_translate("Dialog", "<html><head/><body><p>Version: 0.4.1</p></body></html>"))
self.label_3.setText(_translate("Dialog", "<html><head/><body><p>Youtube-dl is a front-end to youtube-dl - a CLI application. Youtube-dl provides some additional features. Youtube-dl is not released as a part of youtube-dl. Youtube-dl is a separate project and is developed by Muhammad Yasoob Ullah Khalid.This Youtube-dl project version is mainteined by Oleksis Fraga &lt;oleksis.fraga@gmail.com&gt;</p></body></html>"))
self.label_5.setText(_translate("Dialog", "<html><head/><body><p>Youtube-dl uses youtube-dl which is released into Public Domain. It can be downloaded from <a href=\"https://github.com/ytdl-org/youtube-dl\"><span style=\" text-decoration: underline; color:#0000ff;\">youtube-dl repository</span></a></p></body></html>"))
self.label_4.setText(_translate("Dialog", "<html><head/><body><p>Copyright © 2013-2020</p></body></html>"))
Expand Down
2 changes: 1 addition & 1 deletion UI/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.4.0'
__version__ = '0.4.1'
__author__ = 'yasoob'
__maintainer__ = 'Oleksis Fraga'
__maintainer_contact__ = 'oleksis.fraga@gmail.com'
Expand Down
2 changes: 1 addition & 1 deletion UI/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def setupUi(self, MainWindow):

def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "youtube-dl v0.4.0"))
MainWindow.setWindowTitle(_translate("MainWindow", "youtube-dl v0.4.1"))
self.groupBox.setTitle(_translate("MainWindow", "Enter url and download location"))
self.label_2.setText(_translate("MainWindow", "Video URL:"))
self.label_3.setText(_translate("MainWindow", "Save To:"))
Expand Down
6 changes: 2 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,11 @@ def convert_file_browse(self):
else:
self.ui.BrowseConvertLineEdit.files=file_names

# TODO: Fix it
def convert_file(self,file_path, out_path, preferred_format, delete_tmp=False):
if file_path.split('.')[-1] == preferred_format:
self.ui.statusbar.showMessage('The source and destination formats are same')
return

# TODO: Check file_path (file_name to final preferred_format)
if file_path not in self.convert_list:
options= {
'file_path': file_path,
Expand All @@ -136,7 +134,7 @@ def convert_file(self,file_path, out_path, preferred_format, delete_tmp=False):
}
# Using ThreadPool
pprocessorThread = PostProcessor(options)
pprocessorThread.signals.statusSignal.connect(self.ui.statusbar.showMessage)
pprocessorThread.signals.statusBar_Signal.connect(self.ui.statusbar.showMessage)
pprocessorThread.signals.list_Signal.connect(self.add_to_table)
pprocessorThread.signals.row_Signal.connect(self.decrease_rowcount)
self.threadpool.start(pprocessorThread)
Expand Down Expand Up @@ -277,7 +275,7 @@ def closeEvent(self, event):
self.kill_all_threads()

def kill_all_threads(self):
self.threadpool.waitForDone(1)
self.threadpool.waitForDone()
self.close()


Expand Down
2 changes: 1 addition & 1 deletion resources/about-dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Version: 0.4.0&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Version: 0.4.1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion resources/gui_qt-designer-beta.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>youtube-dl v0.4.0</string>
<string>youtube-dl v0.4.1</string>
</property>
<property name="styleSheet">
<string notr="true"/>
Expand Down
4 changes: 2 additions & 2 deletions youtube_dl/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ def is_wellformed(f):
if req_format is None:
req_format = self._default_format_spec(info_dict, download=download)
if self.params.get('verbose'):
self.to_stdout('[debug] Default format spec: %s' % req_format)
self._write_string('[debug] Default format spec: %s\n' % req_format)

format_selector = self.build_format_selector(req_format)

Expand Down Expand Up @@ -1871,7 +1871,7 @@ def dl(name, info):
for ph in self._progress_hooks:
fd.add_progress_hook(ph)
if self.params.get('verbose'):
self.to_stdout('[debug] Invoking downloader on %r' % info.get('url'))
self.to_screen('[debug] Invoking downloader on %r' % info.get('url'))
return fd.download(name, info)

if info_dict.get('requested_formats') is not None:
Expand Down
23 changes: 23 additions & 0 deletions youtube_dl/extractor/cspan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
find_xpath_attr,
get_element_by_class,
int_or_none,
js_to_json,
merge_dicts,
smuggle_url,
unescapeHTML,
)
Expand Down Expand Up @@ -98,6 +100,26 @@ def _real_extract(self, url):
bc_attr['data-bcid'])
return self.url_result(smuggle_url(bc_url, {'source_url': url}))

def add_referer(formats):
for f in formats:
f.setdefault('http_headers', {})['Referer'] = url

# As of 01.12.2020 this path looks to cover all cases making the rest
# of the code unnecessary
jwsetup = self._parse_json(
self._search_regex(
r'(?s)jwsetup\s*=\s*({.+?})\s*;', webpage, 'jwsetup',
default='{}'),
video_id, transform_source=js_to_json, fatal=False)
if jwsetup:
info = self._parse_jwplayer_data(
jwsetup, video_id, require_title=False, m3u8_id='hls',
base_url=url)
add_referer(info['formats'])
ld_info = self._search_json_ld(webpage, video_id, default={})
return merge_dicts(info, ld_info)

# Obsolete
# We first look for clipid, because clipprog always appears before
patterns = [r'id=\'clip(%s)\'\s*value=\'([0-9]+)\'' % t for t in ('id', 'prog')]
results = list(filter(None, (re.search(p, webpage) for p in patterns)))
Expand Down Expand Up @@ -165,6 +187,7 @@ def get_text_attr(d, attr):
formats = self._extract_m3u8_formats(
path, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls') if determine_ext(path) == 'm3u8' else [{'url': path, }]
add_referer(formats)
self._sort_formats(formats)
entries.append({
'id': '%s_%d' % (video_id, partnum + 1),
Expand Down
5 changes: 4 additions & 1 deletion youtube_dl/extractor/drtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DRTVIE(InfoExtractor):
https?://
(?:
(?:www\.)?dr\.dk/(?:tv/se|nyheder|radio(?:/ondemand)?)/(?:[^/]+/)*|
(?:www\.)?(?:dr\.dk|dr-massive\.com)/drtv/(?:se|episode)/
(?:www\.)?(?:dr\.dk|dr-massive\.com)/drtv/(?:se|episode|program)/
)
(?P<id>[\da-z_-]+)
'''
Expand Down Expand Up @@ -111,6 +111,9 @@ class DRTVIE(InfoExtractor):
}, {
'url': 'https://dr-massive.com/drtv/se/bonderoeven_71769',
'only_matching': True,
}, {
'url': 'https://www.dr.dk/drtv/program/jagten_220924',
'only_matching': True,
}]

def _real_extract(self, url):
Expand Down
7 changes: 6 additions & 1 deletion youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,10 @@
EMPFlixIE,
MovieFapIE,
)
from .toggle import ToggleIE
from .toggle import (
ToggleIE,
MeWatchIE,
)
from .tonline import TOnlineIE
from .toongoggles import ToonGogglesIE
from .toutv import TouTvIE
Expand Down Expand Up @@ -1483,6 +1486,8 @@
YandexMusicTrackIE,
YandexMusicAlbumIE,
YandexMusicPlaylistIE,
YandexMusicArtistTracksIE,
YandexMusicArtistAlbumsIE,
)
from .yandexvideo import YandexVideoIE
from .yapfiles import YapFilesIE
Expand Down
5 changes: 4 additions & 1 deletion youtube_dl/extractor/ina.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class InaIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?ina\.fr/(?:video|audio)/(?P<id>[A-Z0-9_]+)'
_VALID_URL = r'https?://(?:(?:www|m)\.)?ina\.fr/(?:video|audio)/(?P<id>[A-Z0-9_]+)'
_TESTS = [{
'url': 'http://www.ina.fr/video/I12055569/francois-hollande-je-crois-que-c-est-clair-video.html',
'md5': 'a667021bf2b41f8dc6049479d9bb38a3',
Expand All @@ -31,6 +31,9 @@ class InaIE(InfoExtractor):
}, {
'url': 'https://www.ina.fr/video/P16173408-video.html',
'only_matching': True,
}, {
'url': 'http://m.ina.fr/video/I12055569',
'only_matching': True,
}]

def _real_extract(self, url):
Expand Down
5 changes: 4 additions & 1 deletion youtube_dl/extractor/mediaset.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MediasetIE(ThePlatformBaseIE):
https?://
(?:(?:www|static3)\.)?mediasetplay\.mediaset\.it/
(?:
(?:video|on-demand)/(?:[^/]+/)+[^/]+_|
(?:video|on-demand|movie)/(?:[^/]+/)+[^/]+_|
player/index\.html\?.*?\bprogramGuid=
)
)(?P<id>[0-9A-Z]{16,})
Expand Down Expand Up @@ -88,6 +88,9 @@ class MediasetIE(ThePlatformBaseIE):
}, {
'url': 'https://www.mediasetplay.mediaset.it/video/grandefratellovip/benedetta-una-doccia-gelata_F309344401044C135',
'only_matching': True,
}, {
'url': 'https://www.mediasetplay.mediaset.it/movie/herculeslaleggendahainizio/hercules-la-leggenda-ha-inizio_F305927501000102',
'only_matching': True,
}]

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions youtube_dl/extractor/pornhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ def add_video_url(video_url):
view_count = self._extract_count(
r'<span class="count">([\d,\.]+)</span> [Vv]iews', webpage, 'view')
like_count = self._extract_count(
r'<span class="votesUp">([\d,\.]+)</span>', webpage, 'like')
r'<span[^>]+class="votesUp"[^>]*>([\d,\.]+)</span>', webpage, 'like')
dislike_count = self._extract_count(
r'<span class="votesDown">([\d,\.]+)</span>', webpage, 'dislike')
r'<span[^>]+class="votesDown"[^>]*>([\d,\.]+)</span>', webpage, 'dislike')
comment_count = self._extract_count(
r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')

Expand Down
2 changes: 1 addition & 1 deletion youtube_dl/extractor/spreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _real_extract(self, url):
class SpreakerShowIE(InfoExtractor):
_VALID_URL = r'https?://api\.spreaker\.com/show/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.spreaker.com/show/3-ninjas-podcast',
'url': 'https://api.spreaker.com/show/4652058',
'info_dict': {
'id': '4652058',
},
Expand Down
Loading

0 comments on commit 88107a7

Please sign in to comment.