Advertisement
Guest User

rygel-extr.patch

a guest
Jun 2nd, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.25 KB | None | 0 0
  1. diff -u ../rygel-0.36.2.5-orig/src/plugins/media-export/rygel-media-export-extractor.vala src/plugins/media-export/rygel-media-export-extractor.vala
  2. --- ../rygel-0.36.2.5-orig/src/plugins/media-export/rygel-media-export-extractor.vala 2018-09-05 03:28:36.000000000 +0800
  3. +++ src/plugins/media-export/rygel-media-export-extractor.vala 2020-05-29 18:41:32.086350939 +0800
  4. @@ -26,30 +26,34 @@
  5. }
  6.  
  7. public class Rygel.MediaExport.Extractor : Object {
  8. - private const string INVALID_CHARS = "()[]<>{}!@#$^&*+=|\\/\"'?~";
  9. - private const string CONVERT_CHARS = "\t_\\.";
  10. - private const string BLOCK_PATTERN = "%s[^%s]*%s";
  11. + private const string INVALID_CHARS = "()[]<>{}!@#$^&*+=|\\/\"'?~;._-";
  12. + private const string BLOCK_PATTERN = "%s[^%s%s]*%s";
  13. private const string[] BLOCKS = { "()", "{}", "[]", "<>" };
  14. private const string[] BLACKLIST = {
  15. - "720p", "1080p", "x264", "ws", "proper", "real.repack", "repack",
  16. - "hdtv", "pdtv", "notv", "dsr", "DVDRip", "divx", "xvid"
  17. + "1080p", "480p", "720p", "AC3", "AMZN"
  18. + , "BD Remux", "BDRip", "Blu Ray", "BLURAY"
  19. + , "DD5 1", "divx", "dsr", "dsrip", "DUB", "DVDRip", "eng", "EniaHD"
  20. + , "h 264", "h264", "h 265", "h265", "HD1080p", "HDCLUB", "HDR1080p"
  21. + , "hdtv", "HDTVRip", "HDwebrip", "HEVC", "HR", "HQ Edition"
  22. + , "Fre", "MP3", "notv", "OM", "pdtv", "proper"
  23. + , "real repack", "Remux", "repack", "rus", "to4ka", "TV"
  24. + , "web dl", "WEB DLRip", "web rip", "webdl", "webrip","ws"
  25. + , "x 264", "x264", "x 265", "x265", "xvid"
  26. };
  27.  
  28. private const string[] VIDEO_SUFFIXES = {
  29. - "webm", "mkv", "flv", "ogv", "ogg", "avi", "mov", "wmv", "mp4",
  30. - "m4v", "mpeg", "mpg", "iso", "mp3", "m4a", "png", "jpg", "jpeg",
  31. - "ogv", "oga", "3gp"
  32. + "3gp", "avi", "flv", "iso", "jpeg", "jpg", "m2ts", "m4a", "m4v"
  33. + , "mkv", "mov", "mp3", "mp4", "mpeg", "mpg", "oga", "ogg", "ogv"
  34. + , "ogv", "png", "ts", "vob", "webm", "wmv"
  35. };
  36.  
  37. private static Regex char_remove_regex;
  38. - private static Regex char_convert_regex;
  39. private static Regex space_compress_regex;
  40. private static Regex[] block_regexes;
  41. private static Regex[] blacklist_regexes;
  42. private static Regex[] video_suffix_regexes;
  43.  
  44. public File file { get; construct set; }
  45. - public bool extract_metadata { get; construct set; default = true; }
  46.  
  47. protected VariantDict serialized_info;
  48.  
  49. @@ -61,7 +65,7 @@
  50. string content_type,
  51. bool extract_metadata) {
  52. if (!extract_metadata) {
  53. - return new Extractor (file, false);
  54. + return new Extractor (file);
  55. }
  56.  
  57. var is_text = content_type.has_prefix ("text/") ||
  58. @@ -82,8 +86,8 @@
  59. return new GenericExtractor (file);
  60. }
  61.  
  62. - private Extractor (File file, bool extract_metadata) {
  63. - Object (file: file, extract_metadata: extract_metadata);
  64. + private Extractor (File file) {
  65. + Object (file: file);
  66. }
  67.  
  68. public override void constructed () {
  69. @@ -99,12 +103,8 @@
  70. FileQueryInfoFlags.NONE);
  71. var display_name = file_info.get_display_name ();
  72.  
  73. - if (extract_metadata) {
  74. - var title = this.strip_invalid_entities (display_name);
  75. - this.serialized_info.insert (Serializer.TITLE, "s", title);
  76. - } else {
  77. - this.serialized_info.insert (Serializer.TITLE, "s", display_name);
  78. - }
  79. + var title = this.strip_invalid_entities (display_name);
  80. + this.serialized_info.insert (Serializer.TITLE, "s", title);
  81.  
  82. var mtime = file_info.get_attribute_uint64
  83. (FileAttribute.TIME_MODIFIED);
  84. @@ -143,26 +143,25 @@
  85. try {
  86. var regex_string = Regex.escape_string (INVALID_CHARS);
  87. char_remove_regex = new Regex ("[%s]".printf (regex_string));
  88. - regex_string = Regex.escape_string (CONVERT_CHARS);
  89. - char_convert_regex = new Regex ("[%s]".printf (regex_string));
  90. space_compress_regex = new Regex ("\\s+");
  91. block_regexes = new Regex[0];
  92.  
  93. foreach (var block in BLOCKS) {
  94. var block_re = BLOCK_PATTERN.printf (
  95. Regex.escape_string ("%C".printf (block[0])),
  96. + Regex.escape_string ("%C".printf (block[0])),
  97. Regex.escape_string ("%C".printf (block[1])),
  98. Regex.escape_string ("%C".printf (block[1])));
  99. block_regexes += new Regex (block_re);
  100. }
  101.  
  102. foreach (var blacklist in BLACKLIST) {
  103. - blacklist_regexes += new Regex (Regex.escape_string
  104. - (blacklist));
  105. + blacklist_regexes += new Regex (Regex.escape_string (" %s ".printf (blacklist)),
  106. + RegexCompileFlags.CASELESS);
  107. }
  108.  
  109. foreach (var suffix in VIDEO_SUFFIXES) {
  110. - var regex = new Regex (Regex.escape_string (suffix),
  111. + var regex = new Regex ("%s$".printf (Regex.escape_string (".%s".printf (suffix))),
  112. RegexCompileFlags.CASELESS);
  113.  
  114. video_suffix_regexes += regex;
  115. @@ -177,20 +176,23 @@
  116. p = original;
  117.  
  118. try {
  119. - foreach (var re in blacklist_regexes) {
  120. - p = re.replace_literal (p, -1, 0, "");
  121. - }
  122. -
  123. foreach (var re in video_suffix_regexes) {
  124. - p = re.replace_literal (p, -1, 0, "");
  125. + p = re.replace_literal (p, -1, 0, " ");
  126. }
  127.  
  128. foreach (var re in block_regexes) {
  129. - p = re.replace_literal (p, -1, 0, "");
  130. + p = re.replace_literal (p, -1, 0, " ");
  131. + }
  132. +
  133. + p = char_remove_regex.replace_literal (p, -1, 0, " ");
  134. +
  135. + // Add spaces for blacklist_regexes works on the left/right sides of p
  136. + p = " %s ".printf (space_compress_regex.replace_literal (p, -1, 0, " "));
  137. +
  138. + foreach (var re in blacklist_regexes) {
  139. + p = re.replace_literal (p, -1, 0, " ");
  140. }
  141.  
  142. - p = char_remove_regex.replace_literal (p, -1, 0, "");
  143. - p = char_convert_regex.replace_literal (p, -1, 0, " ");
  144. p = space_compress_regex.replace_literal (p, -1, 0, " ");
  145.  
  146. p._strip ();
  147. diff -u ../rygel-0.36.2.5-orig/src/plugins/media-export/rygel-media-export-generic-extractor.vala src/plugins/media-export/rygel-media-export-generic-extractor.vala
  148. --- ../rygel-0.36.2.5-orig/src/plugins/media-export/rygel-media-export-generic-extractor.vala 2017-04-19 04:38:35.000000000 +0800
  149. +++ src/plugins/media-export/rygel-media-export-generic-extractor.vala 2020-05-30 10:23:45.527285367 +0800
  150. @@ -37,7 +37,7 @@
  151.  
  152. static construct {
  153. try {
  154. - GenericExtractor.discoverer = new Discoverer (10 * Gst.SECOND);
  155. + GenericExtractor.discoverer = new Discoverer (300 * Gst.SECOND);
  156. GenericExtractor.discoverer.start ();
  157. } catch (Error error) {
  158. debug ("Generic extractor unavailable: %s", error.message);
  159. @@ -55,6 +55,7 @@
  160. public override async void run () throws Error {
  161. yield base.run ();
  162.  
  163. + warning (_("------------ new item ---------------"));
  164. if (GenericExtractor.discoverer == null) {
  165. throw new ExtractorError.GENERAL ("Backend not avaliable");
  166. }
  167. @@ -72,20 +73,32 @@
  168. var path = this.file.get_path ();
  169. var uri = this.file.get_uri ();
  170.  
  171. +
  172. + warning (_("path: %s"), path);
  173. + warning (_("uri: %s"), uri);
  174. + warning (_("sec: %s"), Gst.SECOND.to_string());
  175. +
  176. +
  177. if (path != null) {
  178. uri = Filename.to_uri (path);
  179. }
  180. -
  181. +
  182. +
  183. +
  184. GenericExtractor.discoverer.discover_uri_async (uri);
  185. + //warning (_("uri_1: %s"), uri);
  186. yield;
  187. + //warning (_("uri_2: %s"), uri);
  188. GenericExtractor.discoverer.disconnect (id);
  189. +
  190.  
  191. if (error != null) {
  192. + //warning (_("uri_3: %s"), error.message);
  193. // Re-create discoverer, in error case it tends to get really
  194. // slow.
  195. GenericExtractor.discoverer.stop ();
  196. GenericExtractor.discoverer = null;
  197. - GenericExtractor.discoverer = new Discoverer (10 * Gst.SECOND);
  198. + GenericExtractor.discoverer = new Discoverer (300 * Gst.SECOND);
  199. GenericExtractor.discoverer.start ();
  200.  
  201. var result = info.get_result ();
  202. @@ -142,11 +155,13 @@
  203. // Info has several tags, general and on audio info for music files
  204. var tags = info.get_tags ();
  205. if (tags != null) {
  206. - string? title = null;
  207. - if (tags.get_string (Tags.TITLE, out title)) {
  208. - // If not AVI file, replace title we guessed from filename
  209. - if (this.mime_type != "video/x-msvideo" && title != null) {
  210. - this.serialized_info.insert (Serializer.TITLE, "s", title);
  211. + // If not Video file, replace title we guessed from filename
  212. + if (this.mime_type.substring(0, 5) != "video") {
  213. + string? title = null;
  214. + if (tags.get_string (Tags.TITLE, out title)) {
  215. + if (title != null) {
  216. + this.serialized_info.insert (Serializer.TITLE, "s", title);
  217. + }
  218. }
  219. }
  220.  
  221. @@ -178,6 +193,8 @@
  222. this.serialized_info.insert (Serializer.VIDEO_DEPTH, "i",
  223. vinfo.get_depth () > 0 ?
  224. vinfo.get_depth () : -1);
  225. +
  226. + warning (_("depth: %s"), vinfo.get_depth ().to_string());
  227. }
  228.  
  229. if (audio_streams != null && audio_streams.data != null) {
  230.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement