add support for mtv81 and refactor rtmpdump to support rtmpdump parameters
diff --git a/src/you_get/common.py b/src/you_get/common.py
index 7375c52442..863cba7cf0 100644
--- a/src/you_get/common.py
+++ b/src/you_get/common.py
@@ -675,21 +675,22 @@ def download_urls_chunked(urls, title, ext, total_size, output_dir='.', refer=No
 
     print()
 
-def download_rtmp_url(url, playpath, title, ext, total_size=0, output_dir='.', refer=None, merge=True, faker=False):
+def download_rtmp_url(url,title, ext,params={}, total_size=0, output_dir='.', refer=None, merge=True, faker=False):
     assert url
     if dry_run:
         print('Real URL:\n%s\n' % [url])
-        print('Real Playpath:\n%s\n' % [playpath])
+        if params.get("-y",False): #None or unset ->False
+            print('Real Playpath:\n%s\n' % [params.get("-y")])
         return
 
     if player:
         from .processor.rtmpdump import play_rtmpdump_stream
-        play_rtmpdump_stream(player, url, playpath)
+        play_rtmpdump_stream(player, url, params)
         return
 
     from .processor.rtmpdump import has_rtmpdump_installed, download_rtmpdump_stream
     assert has_rtmpdump_installed(), "RTMPDump not installed."
-    download_rtmpdump_stream(url, playpath, title, ext, output_dir)
+    download_rtmpdump_stream(url,  title, ext,params, output_dir)
 
 def playlist_not_supported(name):
     def f(*args, **kwargs):
diff --git a/src/you_get/extractor/__init__.py b/src/you_get/extractor/__init__.py
index 9c99b80f3d..75544a9f77 100644
--- a/src/you_get/extractor/__init__.py
+++ b/src/you_get/extractor/__init__.py
@@ -26,6 +26,7 @@
 from .magisto import *
 from .miomio import *
 from .mixcloud import *
+from .mtv81 import *
 from .netease import *
 from .nicovideo import *
 from .pptv import *
diff --git a/src/you_get/extractor/__main__.py b/src/you_get/extractor/__main__.py
index 5d16f7bf7c..a7991e47c8 100644
--- a/src/you_get/extractor/__main__.py
+++ b/src/you_get/extractor/__main__.py
@@ -46,6 +46,7 @@ def url_to_module(url):
         'magisto': magisto,
         'miomio': miomio,
         'mixcloud': mixcloud,
+        'mtv81':mtv81,
         'nicovideo': nicovideo,
         'pptv': pptv,
         'qq': qq,
diff --git a/src/you_get/extractor/mtv81.py b/src/you_get/extractor/mtv81.py
new file mode 100644
index 0000000000..bce1e291b0
--- /dev/null
+++ b/src/you_get/extractor/mtv81.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+__all__ = ['mtv81_download']
+
+from ..common import *
+
+from xml.dom.minidom import parseString
+
+from html.parser import HTMLParser
+
+
+def mtv81_download(url, output_dir='.', merge=True, info_only=False):
+    html = get_content(url)
+    title = HTMLParser().unescape(
+        "|".join(match1(html, r"<title>(.*?)</title>").split("|")[:-2]))
+
+    # mgid%3Auma%3Avideo%3Amtv81.com%3A897974
+    vid = match1(html, r'getTheVideo\("(.*?)"')
+    xml = parseString(
+        get_content("http://intl.esperanto.mtvi.com/www/xml/media/mediaGen.jhtml?uri={}&flashPlayer=LNX%2013,0,0,206&geo=CN&sid=123456".format(vid)))
+
+    url = sorted(
+        map(lambda x: x.firstChild.nodeValue, xml.getElementsByTagName("src")),
+        key=lambda x: int(match1(x, r'_(\d+?)_')))[-1]
+
+    mediatype, ext, size = 'mp4', 'mp4', 0
+    print_info(site_info, title, mediatype, size)
+    #
+    # rtmpdump  -r 'rtmpe://cp30865.edgefcs.net/ondemand/mtviestor/_!/intlod/MTVInternational/MBUS/GeoLocals/00JP/VIAMTVI/PYC/201304/7122HVAQ4/00JPVIAMTVIPYC7122HVAQ4_640x_360_1200_m30.mp4' -o "title.mp4" --swfVfy http://media.mtvnservices.com/player/prime/mediaplayerprime.1.10.8.swf
+    #
+    # because rtmpdump is unstable,may try serveral times
+    #
+    if not info_only:
+        # import pdb
+        # pdb.set_trace()
+        download_rtmp_url(url=url, title=title, ext=ext, params={
+                          "--swfVfy": "http://media.mtvnservices.com/player/prime/mediaplayerprime.1.10.8.swf"}, output_dir=output_dir)
+
+
+site_info = "mtv81.com"
+download = mtv81_download
+download_playlist = playlist_not_supported('mtv81')
diff --git a/src/you_get/extractor/theplatform.py b/src/you_get/extractor/theplatform.py
index 2938c459a2..db129c2a8f 100644
--- a/src/you_get/extractor/theplatform.py
+++ b/src/you_get/extractor/theplatform.py
@@ -17,7 +17,7 @@ def theplatform_download_by_pid(pid, title, output_dir='.', merge=True, info_onl
 
     print_info(site_info, title, type, size)
     if not info_only:
-        download_rtmp_url(url=smil_base, playpath=ext+':'+smil_video, title=title, ext=ext, output_dir=output_dir)
+        download_rtmp_url(url=smil_base, title=title, ext=ext,params={"-y":ext+':'+smil_video}, output_dir=output_dir)
 
 site_info = "thePlatform.com"
 download = theplatform_download_by_pid
diff --git a/src/you_get/processor/rtmpdump.py b/src/you_get/processor/rtmpdump.py
index 6f2919792b..8540081940 100644
--- a/src/you_get/processor/rtmpdump.py
+++ b/src/you_get/processor/rtmpdump.py
@@ -16,20 +16,40 @@ def get_usable_rtmpdump(cmd):
 def has_rtmpdump_installed():
     return RTMPDUMP is not None
 
-def download_rtmpdump_stream(url, playpath, title, ext, output_dir='.'):
+#
+#params ={"-y":"playlist","-q":None,} 
+#if Only Key ,Value should be None
+#-r -o should not be included in params 
+
+def download_rtmpdump_stream(url, title, ext,params={},output_dir='.'):
     filename = '%s.%s' % (title, ext)
     filepath = os.path.join(output_dir, filename)
 
-    params = [RTMPDUMP, '-r']
-    params.append(url)
-    params.append('-y')
-    params.append(playpath)
-    params.append('-o')
-    params.append(filepath)
+    cmdline = [RTMPDUMP, '-r']
+    cmdline.append(url)
+    cmdline.append('-o')
+    cmdline.append(filepath)
+
+    for key in params.keys():
+        cmdline.append(key)
+        if params[key]!=None:
+            cmdline.append(params[key])
 
-    subprocess.call(params)
+    # cmdline.append('-y')
+    # cmdline.append(playpath)
+    print("Call rtmpdump:\n"+" ".join(cmdline)+"\n")
+    subprocess.call(cmdline)
     return
 
-def play_rtmpdump_stream(player, url, playpath):
-    os.system("rtmpdump -r '%s' -y '%s' -o - | %s -" % (url, playpath, player))
+#
+#To be refactor
+#
+def play_rtmpdump_stream(player, url, params={}):
+    cmdline="rtmpdump -r '%s' "%url
+    for key in params.keys():
+        cmdline+=key+" "+params[key] if params[key]!=None else ""+" "
+    cmdline+=" -o - | %s -"%player
+    print(cmdline)
+    os.system(cmdline)
+    # os.system("rtmpdump -r '%s' -y '%s' -o - | %s -" % (url, playpath, player))
     return

solved  #258.
