51 elif cleaned_data['src'].startswith("rtmp://"): |
51 elif cleaned_data['src'].startswith("rtmp://"): |
52 cleaned_data['videopath'] = '' |
52 cleaned_data['videopath'] = '' |
53 # If the url is kind of rtmp://site/flv:path/to/file.flv or rtmp://site/mp4:path/to/file.mp4, we parse it. |
53 # If the url is kind of rtmp://site/flv:path/to/file.flv or rtmp://site/mp4:path/to/file.mp4, we parse it. |
54 # If the url is kind of rtmp://site/path/to/file, we don't parse it because we can't get the right streamer. |
54 # If the url is kind of rtmp://site/path/to/file, we don't parse it because we can't get the right streamer. |
55 a = cleaned_data['src'].split(":") |
55 a = cleaned_data['src'].split(":") |
56 if len(a)==3 and (a[1].endswith("flv") or a[1].endswith("mp4") or a[1].endswith("mp3")): |
56 filepart = a[1].lower() if len(a) == 3 else "" |
|
57 if len(a)==3 and (filepart.endswith("flv") or filepart.endswith("mp4") or filepart.endswith("mp3")): |
57 # We update with the good streamer |
58 # We update with the good streamer |
58 cleaned_data['videopath'] = a[0] + ":" + a[1][:-3] |
59 cleaned_data['videopath'] = a[0] + ":" + a[1][:-3] |
59 # We remove the "flv:" from the url because it's useless in the real url |
60 # We remove the "flv:" from the url because it's useless in the real url |
60 if a[1].endswith("flv"): |
61 if filepart.endswith("flv"): |
61 cleaned_data['src'] = a[2] |
62 cleaned_data['src'] = a[2] |
62 else: |
63 else: |
63 cleaned_data['src'] = a[1][-3:] + ":" + a[2] |
64 cleaned_data['src'] = a[1][-3:] + ":" + a[2] |
64 # We remove the ".mp3" at the the end of the src if necessary |
65 # We remove the ".mp3" at the the end of the src if necessary |
65 if a[1].endswith("mp3") and cleaned_data['src'].endswith(".mp3"): |
66 if filepart.endswith("mp3") and cleaned_data['src'].endswith(".mp3"): |
66 cleaned_data['src'] = cleaned_data['src'][:-4] |
67 cleaned_data['src'] = cleaned_data['src'][:-4] |
67 # We get or create the media with the correct datas |
68 # We get or create the media with the correct datas |
68 media, created = Media.objects.get_or_create(src=cleaned_data['src'], defaults=cleaned_data) #@UndefinedVariable |
69 media, created = Media.objects.get_or_create(src=cleaned_data['src'], defaults=cleaned_data) #@UndefinedVariable |
69 |
70 |
70 elif media_input_type == "url" or media_input_type == "upload" : |
71 elif media_input_type == "url" or media_input_type == "upload" : |