summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/YoutubeCom.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-29 17:05:45 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-29 17:05:45 +0200
commit252cf9964a2ebc78a589f75db2a7be0d25cac512 (patch)
tree0f4cd1a7949f8a3dc87eaed35f248170ee421943 /module/plugins/hoster/YoutubeCom.py
parentmany new stuff, some things already working (diff)
downloadpyload-252cf9964a2ebc78a589f75db2a7be0d25cac512.tar.xz
more improvements and cleaned some imports
Diffstat (limited to 'module/plugins/hoster/YoutubeCom.py')
-rw-r--r--module/plugins/hoster/YoutubeCom.py83
1 files changed, 26 insertions, 57 deletions
diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py
index 978d89a37..e40b0c9ad 100644
--- a/module/plugins/hoster/YoutubeCom.py
+++ b/module/plugins/hoster/YoutubeCom.py
@@ -9,71 +9,40 @@ class YoutubeCom(Hoster):
__type__ = "hoster"
__pattern__ = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*"
__version__ = "0.2"
- __config__ = [ ("int", "quality" , "Quality Setting", "hd;lq"),
- ("int", "config", "Config Settings" , "default" ) ]
+ __config__ = [ ("quality", "str" , "Quality Setting", "hd") ]
__description__ = """Youtube.com Video Download Hoster"""
__author_name__ = ("spoob")
__author_mail__ = ("spoob@pyload.org")
-
- def __init__(self, parent):
- Hoster.__init__(self, parent)
- self.parent = parent
- self.html = None
- self.read_config()
- self.hd_available = False
-
- def download_html(self):
- url = self.parent.url
- self.html = self.load(url)
-
- def get_file_url(self):
- """ returns the absolute downloadable filepath
- """
- if self.html == None:
- self.download_html()
-
- videoId = self.parent.url.split("v=")[1].split("&")[0]
- videoHash = re.search(r'&t=(.+?)&', self.html).group(1)
- quality = ""
- if self.config['quality'] == "sd":
- quality = "&fmt=6"
- elif self.config['quality'] == "hd" and self.hd_available:
- quality = "&fmt=22"
- else:
- quality = "&fmt=18"
- file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality
- return file_url
- def verify_config(self):
- q = self.get_config("quality")
- if not (q == "hq" or q == "hd" or q == "sd"):
- self.config["quality"] = "hd"
- hq = self.get_config("high_quality")
- if hq:
- self.remove_config("high_quality")
- self.set_config()
-
- def get_file_name(self):
- if self.html == None:
- self.download_html()
+ def process(self, pyfile):
+ html = self.load(pyfile.url)
+
+ if re.search(r"(.*eine fehlerhafte Video-ID\.)", html) != None:
+ self.offline()
+
+ videoId = pyfile.url.split("v=")[1].split("&")[0]
+ videoHash = re.search(r'&t=(.+?)&', html).group(1)
+
+
file_name_pattern = '<meta name="title" content="(.+?)">'
is_hd_pattern = r"'IS_HD_AVAILABLE': (false|true)"
file_suffix = ".flv"
- is_hd = re.search(is_hd_pattern, self.html).group(1)
- self.hd_available = (is_hd == "true")
- if self.config['quality'] == "hd" or self.config['quality'] == "hq":
+ is_hd = re.search(is_hd_pattern, html).group(1)
+ hd_available = (is_hd == "true")
+
+ if self.getConf("quality") == "hd" or self.getConf("quality") == "hq":
file_suffix = ".mp4"
- name = re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix
+ name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix
- name = name.replace("&amp;", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue")
- return name
+ pyfile.name = name.replace("&amp;", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue")
- def file_exists(self):
- """ returns True or False
- """
- if self.html == None:
- self.download_html()
- if re.search(r"(.*eine fehlerhafte Video-ID\.)", self.html) != None:
- return False
+ if self.getConf("quality") == "sd":
+ quality = "&fmt=6"
+ elif self.getConf("quality") == "hd" and hd_available:
+ quality = "&fmt=22"
else:
- return True
+ quality = "&fmt=18"
+
+ file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality + "&asv=2"
+
+ self.download(file_url) \ No newline at end of file