Open odnar-dev opened 1 year ago
Hey @odnar-dev
I do think that we could have a rewrite of termv, development has slowed down very much due it not being exiting anymore. Creating a new format for termv sound fun, and I'm really intrested in doing so.
I'll take a look into this issue and post my thoughts here when I get time
I've looked into the issue and yeah, making a new format for termv looks promising. A tab seperated .termv file would be best i think instead of using json. I'll be looking more into how to parse m3u8 files and see how it plays with out idea.
hi @Roshan-R , looks like i forget about this :smile: well if you still want to brainstorm some ideas , and pick this up let me know , and i will share with u my progress
Yes, I'd love to do that @odnar-dev, I'll be looking into this and will be sharing my progress
so here is the m3u8 parser i told u about, you give it a m3u8 file
#!/usr/bin/env bash
# m3u8 related
parse_playlist_m3u8(){
local filepath="$@"
IFS= read -r first_line < "${filepath:?}"
case "${first_line}" in
"#EXTM3U"*) printf '%s' "(valide)";;
*) { prnt_err "${filepath:?} don't have a valide m3u8 header" ; return 1 ;};;
esac
while read -r line; do
case "$line" in
"#EXTINF"*)
declare -A metadata=( )
metadata[tv-name]="${line##*,}"
metadata[tv-name]="${metadata[tv-name]%%[[:cntrl:]]}"
metadata[tv-name]="$(echo ${metadata[tv-name]} | tr -d '\r')"
local other_metadata="${line%%,*}"
local other_metadata="${other_metadata#* }"
while IFS="=" read -r key val; do
[ "${key##\#*}" ] || continue
metadata[${key}]="${val//\"}"
done < <(printf '%s\n' ${other_metadata:-} )
;;
"#EXTVLCOPT"*|"#KODIPROP"*|"# ")
;;
*)
[ -z "${metadata[tv-name]}" ] && continue
[ -z "${line}" ] && continue
#[ -z "${metadata[tv-glanguage]}" ] && metadata[tv-glanguage]="${metadata[tvg-language]}"
#[ -z "${metadata[tv-gcountry]}" ] && metadata[tv-gcountry]="${metadata[tvg-country]}"
printf '%s \t %s \t %s \t %s \t %s\n' "${metadata[tv-name]:?}" "${metadata[group-title]:-N/A}" "${metadata[tv-glanguage]:-N/A}" "${metadata[tv-gcountry]:-N/A}" "${line:?}"
declare -A metadata=( )
;;
esac
done < "$filepath"
}
parse_playlist_m3u8 "${@:?}"
check out the repo https://github.com/odnar-dev/termv-rewrite i just uploaded my full progress, and here you can see the whole idea and how it gonna work
git clone --depth 1 https://github.com/odnar-dev/termv-rewrite
cd ./termv-rewrite
chmod +x ./termv
./termv
I'm taking a look into the code and it seems to be a big change with what we have so far, I'll review and put my thoughts here once I go through it
I'm pretty sure we could use awk to parse the m3u8 files, I've been working on that. Couple of things to note
i just wanted to try to create a pure bash m3u8 , just to see if it would work :smile:
the idea here is to just to make termv independent from IPTV-ORG format, we can always add back the support for the iptv-org json format and make it optional.
what type of duplication are you talking about, if you mean duplicated lines (same channel with the same link) can be removed easily, but if you talking about same channel with different link, i think we should keep those
As you said, I feel it would be better if we keep the existing iptv-org json format and then allow users to create .termv files on top of the data source. Most users would be satisfied by just the channels in the iptv-org json
About same channel with different links, I feel we should keep both but find a way to differentiate the two in the fzf dialog. something to think about
I'm very much liking the new direction you are proposing for termv.
Hopefully supporting personal playlists gets implemented in your rewrite @Roshan-R. I'd be very interested and I think it would make this more widely used.
hi @Roshan-R , i think we can't add new features to
termv
in it current form, without a whole rewrite.for now,
termv
act as a terminal client for iptv-org channels, i think the first step is to maketermv
independent from iptv-org and that by introducing our own format for files. for this we can use json file or a simple text file with.termv
extension and store data in it like this:name \t category \t language \t countries \t channelsUrl
with this, we can add the support of multiple sources with different formats, cause we can download the file process it and convert it into our own format. and also the user can create his own channels list easily by creating a file with
.termv
extension.the source list can be loaded form config file with this parameters : source_name, source_url and source_type
we will use the source_url to download file from , use source_name as file_name, then call process function based on source_type.
i created a m3u8 parser using only bash functions, but it slow in large files.