Commit 4648f820 authored by Lysander Trischler's avatar Lysander Trischler

Fix best-of-youtube RSS changes and remove options

parent 98d1a77f
......@@ -48,12 +48,6 @@ Configuration
To set up **boydl** just put the ``boydl`` main Python script it in your
``PATH``.
If you're a *bestofyoutube.com* user, you may want to ignore your already
viewed videos. To accomplish this ``cd`` into your **boydl** directory and
run ``boydl --html-urls > boydl.index``. This will put all videos into
your index file, so **boydl** thinks they were already downloaded
successfully and don't processes them anymore.
**Beware of the following pitfall:** *Don't* create a symbolic link in
``/usr/local/bin`` to ``boydl``, beacuse **boydl** then assumes your index
file is located in the very same directory, too, which isn't true in most
......
......@@ -10,13 +10,11 @@ Via an index every video is downloaded only once.
This is a complete Python rewrite from the former Bash implementation due
to RSS feed migrations.
Usage: boydl [ --help | -h | --version | --html-urls | --youtube-urls ]
Usage: boydl [ --help | -h | --version ]
Options:
--help Display this boydl's help and exit.
--version Display boydl's version and exit.
--html-urls Only print HTML URLs, do not download them.
--youtube-urls Only print YouTube URLs, do not download them.
"""
__author__ = "Lysander Trischler"
......@@ -24,16 +22,14 @@ __copyright__ = "Copyright 2011, Lysander Trischler"
__license__ = "WTFPL"
__maintainer__ = "Lysander Trischler"
__email__ = "software@lyse.isobeef.org"
__version__ = "2.0.1"
__version_info__ = (2, 0, 1)
__version__ = "2.1.0"
__version_info__ = (2, 1, 0)
import os.path
import sys
me = os.path.basename(__file__)
html_urls = False
youtube_urls = False
for arg in sys.argv[1:]:
if arg in ("--help", "-h"):
print(__doc__.strip())
......@@ -41,10 +37,6 @@ for arg in sys.argv[1:]:
elif arg == "--version":
print("%s Version %s" % (me, __version__))
exit(0)
elif arg == "--html-urls":
html_urls = True
elif arg == "--youtube-urls":
youtube_urls = True
else:
sys.stderr.write("%s: Unknown argument `%s'!\n" % (me, arg))
exit(2)
......@@ -56,8 +48,7 @@ import os
rss_url = 'http://feeds.feedburner.com/bestofyoutubedotcom?format=xml'
ydl = 'youtube-dl -wo "' + os.path.expanduser("~") + '/Desktop/%(stitle)s-%(id)s.%(ext)s"'
link_regex = re.compile(r'<a href="(.+?)">')
url_regex = re.compile(r'"(http://www\.youtube\.com/v/.+?)&amp;hl=en_US&amp;fs=1"')
link_regex = re.compile(r'"http://img.youtube.com/vi/(.+)/[0-9]+.jpg"')
index_file = os.path.join(os.path.dirname(__file__), "boydl.index")
error_file = os.path.join(os.path.dirname(__file__), "boydl.error")
......@@ -82,7 +73,7 @@ for item in channel.getElementsByTagName("item"):
url = None
m = link_regex.search(item.getElementsByTagName("description")[0].firstChild.data)
if m:
url =m.group(1)
url = 'http://www.youtube.com/v/%s' % m.group(1)
#
# if description link cannot be parsed use feed proxy's URL
......@@ -113,43 +104,17 @@ for item in channel.getElementsByTagName("item"):
index_stream.close()
if cont: continue
#
# check if only HTML page URLs are requested by the user
#
if html_urls:
print(url)
continue
#
# download HTML page and extract video URL
#
yurl = None
html_stream = urllib.urlopen(url)
for line in html_stream.readlines():
m = url_regex.search(line)
if m:
yurl = m.group(1)
break
html_stream.close()
#
# check if only YouTube video URLs are requested by the user
#
if youtube_urls:
print(yurl)
continue
#
# download video
#
if yurl is None:
if url is None:
sys.stderr.write("%s: Cannot extract YouTube video URL!\n" % me)
else:
index_stream = open(index_file, "ab")
index_stream.write("%s\n" % url)
index_stream.close()
cmd = ydl + ' ' + yurl
cmd = ydl + ' ' + url
print('—' * 80)
exit_code = os.system(cmd) % 255
if exit_code != 0:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment