Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filter out file extension
#1
Hi all,
Am new here so please be nice :). Also new to python coding and am still learning with a lot more learning to be done.

I have coded a simple Python script which takes an m3u playlist and converts it into an XML that is playable with livestreamer pro addon in kodi, thing is, I can't figure out how to pass .TS links thru f4mproxy only and not any .Mp4 / .Mkv links etc

[color=#000000]import os, re

## Enter file location here ie: C:/temp/PythonTests
dir = ' '

## Enter name of playlist less .m3u extension
input_file = ' '
input_extn = '.m3u'
output_file = input_file+'.xml'

in_path = (dir)+'\\'+(input_file)+input_extn
out_path = (dir)+'\\'+(output_file)

in_file = open(in_path, 'r')
in_txt = in_file.read()

out_file = open(out_path, 'w')
m3u_regex = '#.+,(.+?)\n(.+?)\n'


link = in_txt
match = re.compile(m3u_regex).findall(link)
out_file.write ('<streamingInfos>\n\n')
for title, url in match:
    url = url.replace('&', '&amp;').replace('rtmp://$OPT:rtmp-raw=', '').strip()
    title = title.strip()
    out_file.write('<item>\n<title>' + title + '</title>\n<link>plugin://plugin.video.f4mTester/?streamtype=TSDOWNLOADER;name=' + title + '&amp;url=' + url + '</link>\n<thumbnail>' + ' ' + '</thumbnail>\n</item>\n\n')
    # print('<item>\n<title>' + title + '</title>\n<link>plugin://plugin.video.f4mTester/?streamtype=TSDOWNLOADER&amp;url=' + url + '</link>\n<thumbnail>' + ' ' + '</thumbnail>\n</item>\n\n')

out_file.close()
in_file.close()
[/color]
Reply


Messages In This Thread
Filter out file extension - by Kiwi_man82 - Jan-06-2017, 12:43 AM
RE: Filter out file extension - by Mekire - Jan-06-2017, 01:15 AM
RE: Filter out file extension - by Kiwi_man82 - Jan-06-2017, 02:45 AM
RE: Filter out file extension - by ichabod801 - Jan-06-2017, 02:48 AM
RE: Filter out file extension - by snippsat - Jan-06-2017, 02:55 AM
RE: Filter out file extension - by Kiwi_man82 - Jan-06-2017, 03:07 AM
RE: Filter out file extension - by Kiwi_man82 - Jan-06-2017, 07:23 AM
RE: Filter out file extension - by Kiwi_man82 - Jan-08-2017, 03:34 AM
RE: Filter out file extension - by ichabod801 - Jan-08-2017, 04:09 PM
RE: Filter out file extension - by Kiwi_man82 - Jan-08-2017, 09:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  filter every 24 days file (considering file name) RolanRoll 5 2,408 Jun-23-2022, 11:41 AM
Last Post: RolanRoll
  Filter Excel and Convert an Excel File giddyhead 0 2,307 May-13-2021, 06:31 PM
Last Post: giddyhead
  find file not knowing the extension Leon79 6 3,270 Jul-07-2020, 04:44 PM
Last Post: Leon79
  Can't open/read txt file in C extension for Python Rad226 8 4,974 Jun-26-2020, 04:08 PM
Last Post: Rad226
  how to just filter .mp4 in the text file jacklee26 1 2,062 Mar-22-2020, 06:59 AM
Last Post: buran
  How to get file name without the full path details and without extension aruncom2006 1 6,075 Jan-13-2020, 07:37 AM
Last Post: Larz60+
  How to fetch file from a list which match file extension suddhasilsarkar 1 2,906 Jul-30-2019, 11:54 AM
Last Post: Malt
  .py File extension now working Pronger05 5 4,495 Sep-26-2017, 08:50 PM
Last Post: nilamo
  Unable to open files without file extension pstarrett 3 7,422 Dec-25-2016, 09:15 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020