LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 745|回复: 2

Xlyrics-0.4.1的补丁

[复制链接]
发表于 2005-9-9 02:09:05 | 显示全部楼层 |阅读模式
xmms本来有好几个歌词插件
不过一个都不合心意
以前winamp的那个用的太顺手了
后来看到小锁兄弟写的xlyrics,还不错,用了有段时间了
不过有一些地方还是觉的不太爽
今天做了个补丁
两点改动:
一个是取消自动下载歌词,我从来都是去www.51lrc.com自己下载
一个是取消模糊匹配,至少歌词名字要一个字不差。本来模糊匹配的有点离谱,比如黄磊的年华似水,我没有这个歌词。可是有刘若英的年华,就找来放了。
  1. diff -urN xlyrics-0.4.1/src/find.c xlyrics-0.4.1_new/src/find.c
  2. --- xlyrics-0.4.1/src/find.c    2005-04-13 22:31:24.000000000 +0800
  3. +++ xlyrics-0.4.1_new/src/find.c        2005-09-09 01:51:24.000000000 +0800
  4. @@ -63,29 +63,23 @@
  5.                 else
  6.                         res = -1;
  7.         }
  8. -       else
  9. -       {
  10. +       else {
  11.                 tar = ps1;
  12.                 ps1 = extract_title(ps1);
  13.                 free(tar);
  14.                 tar = ps2;
  15.                 ps2 = extract_title(ps2);
  16.                 free(tar);
  17. -               if(not_abs == 1)
  18. -               {
  19. -                       if(strcmp(ps1, ps2) == 0)
  20. -                               res = 0;
  21. -                       else
  22. -                               res = -1;
  23. -               }
  24. +               if(strcmp(ps1, ps2) == 0)
  25. +                       res = 0;
  26.                 else
  27. -               {
  28. -                       if(strstr(ps1, ps2) || strstr(ps2, ps1))
  29. -                               res = 0;
  30. -                       else
  31. -                               res = -1;
  32. -               }
  33. +                       res = -1;
  34.         }
  35. +       /* added by zhllg@linuxsir
  36. +        * In this program, whenever this function is called
  37. +        * not_abs is either 1 or 0, no third situation
  38. +        * so just an "else" is enough
  39. +        */

  40.         free(ps1);
  41.         free(ps2);
  42. diff -urN xlyrics-0.4.1/src/lyrics.c xlyrics-0.4.1_new/src/lyrics.c
  43. --- xlyrics-0.4.1/src/lyrics.c  2005-09-09 01:27:59.000000000 +0800
  44. +++ xlyrics-0.4.1_new/src/lyrics.c      2005-09-09 01:43:49.000000000 +0800
  45. @@ -105,7 +105,7 @@
  46.      struct Song *song;
  47.      FILE *file;
  48.      char buffer[255];
  49. -    char *x;
  50. +    char *ptr; /* modified by zhllg@linuxsir*/
  51.         char *blank = "\t ";
  52.         int line_n=0;

  53. @@ -117,27 +117,27 @@

  54.      while (fgets(buffer, sizeof(buffer), file))
  55.      {
  56. -               if ((x = strchr(buffer, '\r')))/*if the file is windows format */
  57. -                   *x = '\0';
  58. -               if ((x = strchr(buffer, '\n')))
  59. -                       *x = '\0';
  60. -
  61. -               for(x = buffer; isblank(*x); x++) ;
  62. -
  63. -               if ((x[0] == '[') && (isdigit(x[1])))
  64. +               if ((ptr = strchr(buffer, '\r')))/*if the file is windows format */
  65. +                   *ptr = '\0';
  66. +               if ((ptr = strchr(buffer, '\n')))
  67. +                       *ptr = '\0';
  68. +
  69. +               ptr = buffer + strspn(buffer, blank);/* modified by zhllg@linuxsir*/
  70. +
  71. +               if ((ptr[0] == '[') && (isdigit(ptr[1])))
  72.                 {
  73. -                   get_lyrics_line(x, song);
  74. +                   get_lyrics_line(ptr, song);
  75.                 }
  76. -               else if ((x[0] == '[') && !(isdigit(x[1])))
  77. +               else if ((ptr[0] == '[') && !(isdigit(ptr[1])))
  78.                 {
  79. -                   if ((x[1] == 'a') && (x[2] == 'r')) // artist
  80. -                       song->artist = strdup(&x[4]);
  81. -                   else if ((x[1] == 't') && (x[2] == 'i'))    // title
  82. -                       song->title = strdup(&x[4]);
  83. -                   else if ((x[1] == 'a') && (x[2] == 'l'))    // al
  84. -                       song->language = strdup(&x[4]);
  85. -                   else if ((x[1] == 'b') && (x[2] == 'y'))    // author
  86. -                       song->author = strdup(&x[4]);
  87. +                   if ((ptr[1] == 'a') && (ptr[2] == 'r'))     // artist
  88. +                       song->artist = strdup(&ptr[4]);
  89. +                   else if ((ptr[1] == 't') && (ptr[2] == 'i'))        // title
  90. +                       song->title = strdup(&ptr[4]);
  91. +                   else if ((ptr[1] == 'a') && (ptr[2] == 'l'))        // al
  92. +                       song->language = strdup(&ptr[4]);
  93. +                   else if ((ptr[1] == 'b') && (ptr[2] == 'y'))        // author
  94. +                       song->author = strdup(&ptr[4]);
  95.                 }
  96.      }
  97.         /* set the line unmber needed by list.c*/
  98. diff -urN xlyrics-0.4.1/src/xlyrics.c xlyrics-0.4.1_new/src/xlyrics.c
  99. --- xlyrics-0.4.1/src/xlyrics.c 2005-04-17 17:04:30.000000000 +0800
  100. +++ xlyrics-0.4.1_new/src/xlyrics.c     2005-09-09 01:53:58.000000000 +0800
  101. @@ -638,8 +638,11 @@
  102.                                 else if((lyricsfile = find_file_in_dir(lyrics_dir, playfile, i)))
  103.                                         break;
  104.                         }
  105. +/* commented out by zhllg@linuxsir
  106. + * I personally prefer downloading lyrics manually
  107. + */

  108. -                       if(!lyricsfile && !is_downloading)
  109. +/*                     if(!lyricsfile && !is_downloading)
  110.                         {
  111.                                 char *tmp, *ptr;
  112.                                 tmp = (char*)strdup(playfile);
  113. @@ -651,6 +654,7 @@
  114.                                 g_free(tmp);
  115.                         }else if(is_downloading)
  116.                                 is_downloading =  0;
  117. +*/

  118.                         if(lyricsfile)
  119.                                 add_item_to_cache(playfile, lyricsfile);
复制代码
发表于 2005-9-9 11:43:32 | 显示全部楼层
自动下载歌词和模糊匹配其实都是很有用的功能,你不习惯而已。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-9-9 14:20:52 | 显示全部楼层
Post by sejishikong
自动下载歌词和模糊匹配其实都是很有用的功能,你不习惯而已。

不是每首歌都能下载到

显示别的歌的歌词和不显示有什么区别

对于第二点我是很不爽,不是不习惯的问题了,这个我想没有谁会习惯的

I just hope this patch could be useful to others
Use it at your own discretion
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表