mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-15 12:22:18 +02:00
ISSUE-15 ISSUE-14 ISSUE-13
fixed suffix/prefix tag problems added new fields to mapping attributes and assignments
This commit is contained in:
@@ -1,4 +1,19 @@
|
||||
# Changelog
|
||||
# v0.9.8(2023-02-25)
|
||||
* Added new fields to mapping attributes and assignments
|
||||
- "name"
|
||||
- "title"
|
||||
- "group"
|
||||
- "id"
|
||||
- "chno"
|
||||
- "logo"
|
||||
- "logo_small"
|
||||
- "parent_code"
|
||||
- "audio_track"
|
||||
- "time_shift"
|
||||
- "rec"
|
||||
- "source"
|
||||
|
||||
# v0.9.7(2023-02-15)
|
||||
* Breaking changes, mappings.yml refactored
|
||||
* Added `threads` property to config, which executes different sources in threads.
|
||||
|
||||
Generated
+1
-1
@@ -1066,7 +1066,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "m3u-filter"
|
||||
version = "0.9.6"
|
||||
version = "0.9.7"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-files",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "m3u-filter"
|
||||
version = "0.9.6"
|
||||
version = "0.9.7"
|
||||
edition = "2018"
|
||||
|
||||
[profile.release]
|
||||
|
||||
@@ -246,12 +246,18 @@ but lacks a few features like look around and backreferences.
|
||||
|
||||
#### 2.3.4.2 `attributes`
|
||||
Attributes is a map of key value pairs. Valid keys are:
|
||||
- name
|
||||
- group
|
||||
- title
|
||||
- logo
|
||||
- id
|
||||
- chno
|
||||
- `id`
|
||||
- `chno`
|
||||
- `name`
|
||||
- `group`
|
||||
- `title`
|
||||
- `logo`
|
||||
- `logo_small`
|
||||
- `parent_code`
|
||||
- `audio_track`
|
||||
- `time_shift`
|
||||
- `rec`
|
||||
- `source`
|
||||
|
||||
If the regexps matches, the given fields will be set to the new value
|
||||
|
||||
@@ -293,11 +299,18 @@ If the regexps matches, the given fields will be prefixed to field value
|
||||
|
||||
#### 2.3.4.5 `assignments`
|
||||
Attributes is a map of key value pairs. Valid keys and values are:
|
||||
- name
|
||||
- group
|
||||
- title
|
||||
- id
|
||||
- chno
|
||||
- `id`
|
||||
- `chno`
|
||||
- `name`
|
||||
- `group`
|
||||
- `title`
|
||||
- `logo`
|
||||
- `logo_small`
|
||||
- `parent_code`
|
||||
- `audio_track`
|
||||
- `time_shift`
|
||||
- `rec`
|
||||
- `source`
|
||||
|
||||
Example configuration is:
|
||||
```
|
||||
|
||||
+16
-4
@@ -1,11 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "No argument supplied. First argument should be version number like 1.0.0"
|
||||
exit 1
|
||||
if ! command -v cargo-set-version &> /dev/null
|
||||
then
|
||||
echo "cargo-set-version could not be found. install it with 'cargo install cargo-edit'"
|
||||
exit
|
||||
fi
|
||||
|
||||
VERSION=v$1
|
||||
#if [[ -z "$1" ]]; then
|
||||
# echo "No argument supplied. First argument should be version number like 1.0.0"
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
cd ./frontend || (echo "cant find frontend directory" && exit)
|
||||
NEW_VERSION=$(yarn version --patch | grep "New version" | grep -Po "(\d+\.)+\d+")
|
||||
cd ..
|
||||
cargo-set-version set-version ./Cargo.toml "$NEW_VERSION"
|
||||
|
||||
|
||||
VERSION=v$NEW_VERSION
|
||||
LIN_DIR=m3u-filter_${VERSION}_linux_x86_64
|
||||
WIN_DIR=m3u-filter_${VERSION}_windows_x86_64
|
||||
DARWIN_DIR=m3u-filter_${VERSION}_darwin_x86_64
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "m3u-filter",
|
||||
"description": "m3u-filter",
|
||||
"author": "euzu",
|
||||
"version": "0.9.8",
|
||||
"version": "0.9.7",
|
||||
"private": true,
|
||||
"homepage": "./",
|
||||
"scripts": {
|
||||
|
||||
+14
-11
@@ -5,7 +5,9 @@ use crate::m3u::{FieldAccessor, PlaylistItem};
|
||||
use crate::model::{ItemField, MAPPER_ATTRIBUTE_FIELDS, MAPPER_PREFIX_SUFFIX_FIELDS};
|
||||
|
||||
fn default_as_false() -> bool { false }
|
||||
|
||||
fn default_as_empty_str() -> String { String::from("") }
|
||||
|
||||
fn default_as_empty_map() -> HashMap<String, String> { HashMap::new() }
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
@@ -92,7 +94,7 @@ impl MappingValueProcessor<'_> {
|
||||
fn get_property(&self, key: &str) -> Option<String> {
|
||||
match self.pli.header.get_field(key) {
|
||||
Some(value) => Some(String::from(value)),
|
||||
_=> None
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,24 +125,26 @@ impl MappingValueProcessor<'_> {
|
||||
for mapping_tag in &self.mapper._tags {
|
||||
if mapping_tag.name.eq(tag_capture) {
|
||||
// we have the right tag, now get all captured values
|
||||
let mut captured_tag_values : Vec<&str> = Vec::new();
|
||||
let mut captured_tag_values: Vec<&str> = Vec::new();
|
||||
for cap in &mapping_tag.captures {
|
||||
match captures.get(&cap) {
|
||||
Some(cap_value) => captured_tag_values.push(cap_value),
|
||||
_ => {
|
||||
if verbose { println!("Cant find any tag match for {}", tag_capture) }
|
||||
return None
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
if captured_tag_values.len() > 0 {
|
||||
let captured_text = captured_tag_values.join(&mapping_tag.concat);
|
||||
if captured_text.trim().len() > 0 {
|
||||
let replacement = if captured_text.trim().len() > 0 {
|
||||
// Now we have all our captured values, lets create the tag
|
||||
new_value = new_value.replace(
|
||||
format!("<tag:{}>", mapping_tag.name).as_str(),
|
||||
format!("{}{}{}", &mapping_tag.prefix, captured_text, &mapping_tag.suffix).as_str());
|
||||
}
|
||||
format!("{}{}{}", &mapping_tag.prefix, captured_text, &mapping_tag.suffix)
|
||||
} else {
|
||||
// nothing found so replace tag with empty string
|
||||
String::from("")
|
||||
};
|
||||
new_value = new_value.replace(format!("<tag:{}>", mapping_tag.name).as_str(), replacement.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,13 +197,12 @@ impl MappingValueProcessor<'_> {
|
||||
match self.get_property(value) {
|
||||
Some(prop_value) => {
|
||||
self.set_property(key, &prop_value, verbose);
|
||||
},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl ValueProcessor for MappingValueProcessor<'_> {
|
||||
@@ -275,7 +278,7 @@ pub struct MappingDefinition {
|
||||
impl MappingDefinition {
|
||||
pub(crate) fn prepare(&mut self, verbose: bool) {
|
||||
match &mut self.templates {
|
||||
Some(templates) =>self.templates = Some(prepare_templates(templates, verbose)),
|
||||
Some(templates) => self.templates = Some(prepare_templates(templates, verbose)),
|
||||
_ => {}
|
||||
};
|
||||
for mapping in &mut self.mapping {
|
||||
|
||||
+10
-2
@@ -1,6 +1,14 @@
|
||||
use enum_iterator::Sequence;
|
||||
|
||||
pub const MAPPER_ATTRIBUTE_FIELDS: &[&str] = &["name", "title", "group", "id", "chno"];
|
||||
pub const MAPPER_ATTRIBUTE_FIELDS: &[&str] = &[
|
||||
"name", "title", "group", "id", "chno", "logo",
|
||||
"logo_small",
|
||||
"parent_code",
|
||||
"audio_track",
|
||||
"time_shift",
|
||||
"rec",
|
||||
"source",
|
||||
];
|
||||
pub const MAPPER_PREFIX_SUFFIX_FIELDS: &[&str] = &["name", "title", "group"];
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Sequence)]
|
||||
@@ -33,7 +41,7 @@ pub enum ProcessingOrder {
|
||||
#[serde(rename = "mfr")]
|
||||
MFR,
|
||||
#[serde(rename = "mrf")]
|
||||
MRF
|
||||
MRF,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ProcessingOrder {
|
||||
|
||||
Reference in New Issue
Block a user