| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,39 +22,9 @@ | |||
| 22 | 22 | ||
| 23 | 23 | static hexchat_plugin *ph; /* plugin handle */ | |
| 24 | 24 | ||
| 25 | - BOOL winamp_found = FALSE; | ||
| 26 | - | ||
| 27 | - int status = 0; | ||
| 28 | - | ||
| 29 | - /* Slightly modified from X-Chat's log_escape_strcpy */ | ||
| 30 | - static char * | ||
| 31 | - song_strcpy (char *dest, char *src) | ||
| 32 | - { | ||
| 33 | - while (*src) | ||
| 34 | - { | ||
| 35 | - *dest = *src; | ||
| 36 | - dest++; | ||
| 37 | - src++; | ||
| 38 | - | ||
| 39 | - if (*src == '%') | ||
| 40 | - { | ||
| 41 | - dest[0] = '%'; | ||
| 42 | - dest++; | ||
| 43 | - } | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - dest[0] = 0; | ||
| 47 | - return dest - 1; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | 25 | static int | |
| 51 | 26 | winamp(char *word[], char *word_eol[], void *userdata) | |
| 52 | 27 | { | |
| 53 | - wchar_t wcurrent_play[2048]; | ||
| 54 | - char *current_play, *p; | ||
| 55 | - char p_esc[2048]; | ||
| 56 | - char cur_esc[2048]; | ||
| 57 | - char truc[2048]; | ||
| 58 | 28 | HWND hwndWinamp = FindWindowW(L"Winamp v1.x",NULL); | |
| 59 | 29 | ||
| 60 | 30 | if (hwndWinamp) | |
@@ -98,7 +68,9 @@ winamp(char *word[], char *word_eol[], void *userdata) | |||
| 98 | 68 | } | |
| 99 | 69 | else if (!word_eol[2][0]) | |
| 100 | 70 | { | |
| 101 | - int len = GetWindowTextW(hwndWinamp, wcurrent_play, sizeof(wcurrent_play)); | ||
| 71 | + wchar_t wcurrent_play[2048]; | ||
| 72 | + char *current_play, *p; | ||
| 73 | + int len = GetWindowTextW(hwndWinamp, wcurrent_play, G_N_ELEMENTS(wcurrent_play)); | ||
| 102 | 74 | ||
| 103 | 75 | current_play = g_utf16_to_utf8 (wcurrent_play, len, NULL, NULL, NULL); | |
| 104 | 76 | if (!current_play) | |
@@ -109,36 +81,33 @@ winamp(char *word[], char *word_eol[], void *userdata) | |||
| 109 | 81 | ||
| 110 | 82 | if (strchr(current_play, '-')) | |
| 111 | 83 | { | |
| 112 | - | ||
| 84 | + /* Remove any trailing text and whitespace */ | ||
| 113 | 85 | p = current_play + strlen(current_play) - 8; | |
| 114 | 86 | while (p >= current_play) | |
| 115 | 87 | { | |
| 116 | - if (!strnicmp(p, "- Winamp", 8)) break; | ||
| 117 | - p--; | ||
| 88 | + if (!strnicmp(p, "- Winamp", 8)) | ||
| 89 | + break; | ||
| 90 | + p--; | ||
| 118 | 91 | } | |
| 119 | 92 | ||
| 120 | 93 | if (p >= current_play) | |
| 121 | 94 | p--; | |
| 122 | 95 | ||
| 123 | 96 | while (p >= current_play && *p == ' ') | |
| 124 | 97 | p--; | |
| 125 | - *++p=0; | ||
| 126 | - | ||
| 127 | - p = strchr(current_play, '.') + 1; | ||
| 128 | - | ||
| 129 | - song_strcpy(p_esc, p); | ||
| 130 | - song_strcpy(cur_esc, current_play); | ||
| 98 | + *++p = '\0'; | ||
| 131 | 99 | ||
| 100 | + /* Ignore any leading track number */ | ||
| 101 | + p = strstr (current_play, ". "); | ||
| 132 | 102 | if (p) | |
| 133 | - { | ||
| 134 | - sprintf(truc, "me is now playing:%s", p_esc); | ||
| 135 | - } | ||
| 103 | + p += 2; | ||
| 136 | 104 | else | |
| 137 | - { | ||
| 138 | - sprintf(truc, "me is now playing:%s", cur_esc); | ||
| 139 | - } | ||
| 105 | + p = current_play; | ||
| 140 | 106 | ||
| 141 | - hexchat_commandf(ph, truc); | ||
| 107 | + if (*p != '\0') | ||
| 108 | + hexchat_commandf (ph, "me is now playing: %s", p); | ||
| 109 | + else | ||
| 110 | + hexchat_print (ph, "Winamp: No song information found."); | ||
| 142 | 111 | g_free (current_play); | |
| 143 | 112 | } | |
| 144 | 113 | else | |
| Back | FazBrowse Home | New Git URL |
0 commit comments